akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

ll fac[MAX_N], inv[MAX_N], fiv[MAX_N]; //fiv:inv(fac(i))

ll mod_pow(ll a, ll n) {
	if(n == 0) return 1;
	ll res = mod_pow(a, n / 2);
	if(n % 2 == 0) return res * res % mod;
	else return a * res % mod * res % mod;
}

ll invf(ll a) {
	return mod_pow(a, mod - 2);
}

void C_init(int n) {
	fac[0] = fac[1] = 1; inv[1] = 1;
	fiv[0] = fiv[1] = 1;
	rep(i, 2, n + 1) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fiv[i] = fiv[i - 1] * inv[i] % mod;
	}
}

ll C(int a, int b) { //assume a >= b
	if(a < b || a < 0 || b < 0) return 0;
	return fac[a] * fiv[b] % mod * fiv[a - b] % mod;
}


int N, M;
ll ans[MAX_N];

void solve() {
	cin >> N >> M;
	bool flipped = false;
	C_init(N + M + 10);
	if(N > M) {
		swap(N, M);
		flipped = true;
	}
	rep(i, 0, N) ans[i] = inv[2];
	ll t2 = mod_pow(2, N - 1);
	ll t1 = 0;
	// debug(t2);
	rep(i, N, N + M) {
		MUL(t2, 2);
		MUL(t1, 2);
		ADD(t2, mod - C(i - 1, N - 1));
		if(i >= M) {
			ADD(t2, mod - C(i - 1, i - M));
			ADD(t1, C(i - 1, i - M));
		}
		ans[i] = (t1 + t2 * inv[2] % mod) % mod * invf(mod_pow(2, i)) % mod;
		// debug(i, ans[i], t1, t2);
	}

	rep(i, 0, N + M) {
		if(flipped) cout << (1 + mod - ans[i]) % mod << "\n";
		else cout << ans[i] << "\n";
	}
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 10368
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"
int main()
{
	int i,n;
	ll s=0;
	cin>>n;
	vi a(n);
	for0(i,n){cin>>a[i]; s+=a[i];}
	sort(a.begin(),a.end());
	if(s%10==0){
		int ck=0;
		for(i=0 ; i<n ; i++){
			if(a[i]%10!=0){
				s -= a[i];
				ck=1;
				break;
				}
			}
		if(ck==0){cout<<0<<nw; return 0;}
		}
	cout<<s<<nw;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(br.readLine());
		}
		int[] b = new int[n];
		for (int i = 0; i < n; i++) {
			b[i] = Integer.parseInt(br.readLine());
		}
		br.close();

		int mod = 1000000007;
		Arrays.sort(a);
		Arrays.sort(b);

		long ans = 1;
		int ai = 0;
		int bi = 0;
		Queue<Integer> qa = new ArrayDeque<>();
		Queue<Integer> qb = new ArrayDeque<>();
		while (ai < n || bi < n) {
			if (ai < n && (bi == n || a[ai] < b[bi])) {
				if (qb.isEmpty()) {
					qa.add(a[ai]);
				} else {
					ans *= qb.size();
					ans %= mod;
					qb.poll();
				}
				ai++;
			} else {
				if (qa.isEmpty()) {
					qb.add(b[bi]);
				} else {
					ans *= qa.size();
					ans %= mod;
					qa.poll();
				}
				bi++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 45300
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int a, b, c, num[100010];
    string s, t;

    cin >> a >> b >> c;

    if ((double)(b / a) > (double)(c)) {
        cout << c << endl;
    }
    else {
        cout << (b / a) << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int n;
    cin >> n;
    if(n%1000==0){
        cout << 0 << endl;
        return 0;
    }
    int ans = 1000 - n%1000;
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<stdio.h>
int main()
{
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  int temp=a;
  a=b;
  b=temp;
  temp=c;
  c=a;
  a=temp;
  printf("%d %d %d",a,b,c);
  return 0;
}

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

const int MXN=200005;
const int OFF=1<<18;

int n,m;
ll t[2*OFF];
ll p[2*OFF];
vector<array<int,2>>add[MXN];
vector<array<int,2>>del[MXN];

void propagate(int x){
  t[2*x+1]+=p[x];
  p[2*x+1]+=p[x];
  t[2*x+2]+=p[x];
  p[2*x+2]+=p[x];
  p[x]=0;
}

void upd(int l,int r,ll v,int lo=0,int hi=OFF,int x=0){
  if(r<=lo||hi<=l)return;
  if(l<=lo&&hi<=r){
    t[x]+=v;
    p[x]+=v;
    return;
  }
  propagate(x);
  int md=(lo+hi)/2;
  upd(l,r,v,lo,md,2*x+1);
  upd(l,r,v,md,hi,2*x+2);
  t[x]=max(t[2*x+1],t[2*x+2]);
}

ll get(int l,int r,int lo=0,int hi=OFF,int x=0){
  if(r<=lo||hi<=l)return -1e18;
  if(l<=lo&&hi<=r)return t[x];
  propagate(x);
  int md=(lo+hi)/2;
  return max(get(l,r,lo,md,2*x+1),get(l,r,md,hi,2*x+2));
}

int main(){
  scanf("%d%d",&n,&m);
  for(int i=1;i<=m;++i){
    int l,r,a;
    scanf("%d%d%d",&l,&r,&a);
    add[l].push_back({r,a});
    del[r].push_back({l,a});
  }
  ll curr=0;
  for(int i=1;i<=n;++i){
    for(auto&a:add[i])upd(i,a[0]+1,-a[1]),curr+=a[1];
    upd(i,i+1,get(0,i)+curr);
    for(auto&a:del[i])upd(a[0],i+1,+a[1]),curr-=a[1];
  }
  printf("%lld\n",get(0,n+1));
}


Measured memory_bytes: 29824
#include <bits/stdc++.h>
using namespace std;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
constexpr int MAX = 1e6;
constexpr int NIL = -1;
struct Node { int location, p{NIL}, l{NIL}, r{NIL}; };
class Point {
public:
	int id, x, y;
	Point() : id(-1), x(0), y(0) {}
	Point(int id, int x, int y) : id(id), x(x), y(y) {}
	inline bool operator < ( const Point &p) const {
		return id < p.id;
	}
};
Point P[MAX];
Node T[MAX];
int np{-1};
inline bool lessX(const Point &p1, const Point &p2) { return p1.x < p2.x; }
inline bool lessY(const Point &p1, const Point &p2) { return p1.y < p2.y; }
inline int makeKDTree(int l, int r, bool depth) {
	if(l >= r) return NIL;
	int mid = (l + r) / 2;
	int t = ++np;
	sort(P + l, P + r, (depth ? lessY : lessX));
	T[t].location = mid;
	T[t].l = makeKDTree(l, mid, !depth);
	T[t].r = makeKDTree(mid + 1, r, !depth);
	return t;
}
vi ans;
inline void find(int v, int &sx, int &tx, int &sy, int &ty, bool depth) {
	int x = P[T[v].location].x;
	int y = P[T[v].location].y;
	if(sx <= x && x <= tx && sy <= y && y <= ty) {
		ans.eb(P[T[v].location].id);
	}
	if(!depth) {
		if(T[v].l != NIL && sx <= x) find(T[v].l, sx, tx, sy, ty, !depth);
		if(T[v].r != NIL && x <= tx) find(T[v].r, sx, tx, sy, ty, !depth);
	} else {
		if(T[v].l != NIL && sy <= y) find(T[v].l, sx, tx, sy, ty, !depth);
		if(T[v].r != NIL && y <= ty) find(T[v].r, sx, tx, sy, ty, !depth);
	}
}
int main() {
	int N; scanf("%d", &N);
	int x, y;
	rep(i, 0, N) {
		scanf("%d %d", &x, &y);
		P[i] = Point(i, x, y);
	}
	int root = makeKDTree(0, N, 0);
	int q; cin >> q;
	int sx, tx, sy, ty;
	ans.reserve(MAX);
	rep(i, 0, q) {
		scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
		ans.clear();
		find(root, sx, tx, sy, ty, 0);
		sort(all(ans));
		rep(j, 0, len(ans)) printf("%d\n", ans[j]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 30628
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);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 (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
/*----------------------------------------------------------------------------------*/

int dp[100010];

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

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

        int sum = 6;
        while (sum <= i) {
            chmin(dp[i] ,dp[i-sum] + 1);
            sum*=6;
        }

        sum = 9;
        while (sum <= i) {
            chmin(dp[i], dp[i-sum]+1);
            sum*=9;
        }
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
    int a,b,c,cnt;
    cnt = 0;
    scanf("%d %d %d", &a,&b,&c);
    for (;a<=b;a++)
    {
        if (c%a == 0)
        {
            cnt += 1;
        }
    }
    printf("%d\n", cnt);
    return 0;
}



Measured memory_bytes: 2124
n,k,*a=`dd`.split.map &:to_i;45.downto(r=t=0){|i|z=1<<i;c=a.count{|x|x&z>0};r,t=t|z>k||n<=c*2?[r+c*z,t]:[r+(n-c)*z,t|z]};p r

Measured memory_bytes: 11008
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

bool B[26]{};

int main() {
  string S;
  cin >> S;
  for (int i = 0; i < S.size(); ++i) {
    if (B[S[i] - 'a']) {
      printf("no\n");
      return 0;
    } else {
      B[S[i] - 'a'] = true;
    }
  }
  printf("yes\n");
}

Measured memory_bytes: 3132
#include<stdio.h>
#include<string.h>
int main(){
char a[20],b[30];
int ans=0,n,i,j,x,k,l,m=0;
fgets(a,15,stdin);
x=strlen (a)-1;
scanf("%d\n",&n);
for(i=0;i<n;i++){
for(j=0;j<10;j++){
scanf("%c",&b[j]);
}
scanf("\n");
for(j=0;j<10;j++){
b[j+10]=b[j];
}
for(j=0;j<10;j++){
for(k=j,l=0;k<j+x;k++,l++){
if(a[l]!=b[k]){
m=1;
break;
}
}
if(m==0){
ans++;
break;
}
m=0;
}
}
printf("%d\n",ans);
return 0;
}


Measured memory_bytes: 2036
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<stdio.h>
using namespace std;
 
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<25
 
int main()
{
	int n;
	cin >> n;
	if (n == 7 || n == 5 || n == 3) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
vector<int> solve(int n){
    vector<int>ans(n);
    vector<bool>used(300001,false);
    ll sum = 0;
    int cnt = 0;
    for(int i = 2;i <= 300000;i++){
        if((__gcd(i,6)!=1) and !used[i]){
            ans[cnt] = i;
            used[i] = true;
            sum+=i;
            cnt++;
        }
        if(cnt==n-1)break;
    }
    for(int i = 2;i <= 300000;i++){
        if(!used[i] and (sum+i)%6==0 and __gcd(sum,(ll)i)!=1){
            ans[cnt] = i;
            sum+=i;
            //show(sum);
            break;
        }
    }
    
    return ans;
}
bool check(vector<int> &ans){
    sort(ans.begin(),ans.end());
    int n = (int)ans.size();
    rep(i,n-1){
        if(ans[i]==ans[i+1])return false;
    }
    int k = ans[0];
    ll sum = 0;
    rep(i,ans.size()){
        k = __gcd(k,ans[i]);
        sum+=ans[i];
    }
    show(sum);
    if(k!=1)return false;
    rep(i,ans.size()){
        if(__gcd(sum-(ll)ans[i],(ll)ans[i])==1){
            return false;
        }
    }
    return true;
}
int main(){
    int n;
    cin >> n;
    auto res = solve(n);
    if(1){
        rep(i,n-1){
            cout << res[i] << " ";
        }
        cout << res[n-1] << endl;
    }else{
        //cout << "WA" << endl;
    }
    return 0;
}

Measured memory_bytes: 1144
import sys
input = sys.stdin.buffer.readline
import copy

def main():
    N,K = map(int,input().split())
    MOD = 10**9+7

    fac = [0 for _ in range(2*10**5+1)]
    fac[0],fac[1] = 1,1
    inv = copy.deepcopy(fac)
    invfac = copy.deepcopy(fac)
    
    for i in range(2,2*10**5+1):
        fac[i] = (fac[i-1]*i)%MOD
        inv[i] = MOD-(MOD//i)*inv[MOD%i]%MOD
        invfac[i] = (invfac[i-1]*inv[i])%MOD

    def coef(x,y):
        num = (((fac[x]*invfac[y])%MOD)*invfac[x-y]%MOD)
        return num
    
    ans = 0
    for i in range(min(N,K+1)):
        a = coef(N,i)
        b = coef(N-1,N-i-1)
        ans += ((a*b)%MOD)
        
    print(ans%MOD)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 27356
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define Rep(i, s, n) for (int i = (int)s; i < (int)n; i++)
typedef long long ll;

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

    int r;
    cin >> r;
    cout << 3 * r * r << endl;
}

Measured memory_bytes: 3580
#include <iostream>
#include <fstream>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define pb push_back

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

const int mod = (int)1e9 + 7;
const int mod2 = 998244353;

ll exp(ll taban, ll us, ll md) {
    ll carpan = taban % md;
	if(carpan == 0) return 0;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % md;
        temp /= 2;
        carpan = (carpan*carpan) % md;
    }
    return res;
}
 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}

ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}

ll mul(ll a, ll b, ll md){
	return a*b % md;
}

vector<ll> fact;
vector<ll> inv_fact;
void fact_init(int n){
	fact.resize(n+5);
	inv_fact.resize(n+5);
	fact[0] = inv_fact[0] = 1;
	for(int i = 1; i <= n; i++){
		fact[i] = (fact[i-1] * i) % mod;
		inv_fact[i] = exp(fact[i], mod-2, mod);
	}
}

ll komb(ll a, ll b){
	if(a < b) return 0;
	return fact[a] * (inv_fact[a-b] * inv_fact[b] % mod) % mod;
}

const int N = 1e5+5;

int main(){
	ios::sync_with_stdio(false); cin.tie(NULL);
	int x, y; cin>>x>>y;
	//int a = 0, b;
	//2a + 4b = y
	//a + b = x
	//b = x-a
	//4x - 2a = y
	//2a = 4x - y
	if((4*x - y) % 2 == 0 && x - (4*x-y)/2 >= 0 && 4*x >= y) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rp(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
using G=vector<vector<int>>;

int main(){
    int a,b;
    cin >> a >>b;
    cout << a + b/2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>

#include<deque>
#define pi 3.141592653589793238
#include<chrono>

#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define f0 get<0>
#define f1 get<1>
#define f2 get<2>
#define db double
using namespace std;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool prime(ll n)
{
    if(n <= 1){
        return false;
    }
    ll i;
    for (i = 2; i * i <= n; i++)
    {
        if (n % i == 0)
            return false;
    }
    return true;
}
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    //cin >> T;
    while (T--) {
        ll n;
        cin >> n;
        ll nn = n;
        ll count = 0;
        ll ans = 0;
        if(prime(n)){
            cout << 1 ;
            return 0;
        }
        for(i = 2 ; i*i <= n; i++){
            
            ll pow = 0;
            if(n % i == 0){
                while(n % i == 0 && n > 0){
                    pow++;
                    n = n / i;
                }
                
            }
            ll k = 1;
            while(pow >= k){
                pow -= k;
                k++;
                ans++;
            }
            //cout << n << endl;
        }
        if(n > 1){
            ans++;
        }
        cout << ans;
        
    }
    
    return 0;
}


Measured memory_bytes: 3644
import java.util.Arrays;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        int[] x = new int[3];
        for(int i = 0; i < 3; i++){
            x[i] = scn.nextInt();
        }
        Arrays.sort(x);
        System.out.println(x[0]+" "+x[1]+" "+x[2]);
    }
}


Measured memory_bytes: 26420
# 同じ町に二回到達したときに、前回たどり着いたときとの差を観る

import sys

N, K = map(int, input().split())
A = list(map(int, input().split()))

Flag = [0] * (N+1)
X = [0] * (N + 1)
X[0] = 1

for i in range(1, K + 1):
    if Flag[A[X[i - 1] - 1]] == 1:
        # 前回の位置を取得
        hoge = X.index(A[X[i - 1] - 1])
        print(X[hoge + ((K - hoge) % ((i-1) - hoge + 1))])
        sys.exit()
    else:
        X[i] = A[X[i - 1] - 1]
        Flag[A[X[i - 1] - 1]] = 1


print(X[K])


Measured memory_bytes: 92580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll k, n;
  cin >> k >> n;
  vector<ll> a(2 * n);
  REP(i, n) {
    cin >> a[i];
    a[i + n] = a[i] + k;
  }
  ll ans = 1e18;
  REP(i, n) { ans = min(ans, a[i + n - 1] - a[i]); }
  cout << ans << endl;
}

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

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if ((a < b && c < b && a < c)
      || (b < a && b < c && c < a))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define P 1000000007
#define M 1000005
using namespace std;
LL ans=0;
int mkx[M],mky[M],tx,ty,x[M],y[M];
vector<int>edge[M];
bool mark[M];
int L,R,E;
void dfs(int x) {
	E++;
	if(mark[x])return;
	mark[x]=1;
	if(x<=tx)L++;
	else R++;
	for(int i=0; i<edge[x].size(); i++)
		dfs(edge[x][i]);
}
int main() {
	int n;
	cin>>n;
	for(int i=1; i<=n; i++) {
		scanf("%d %d",&x[i],&y[i]);
		if(!mkx[x[i]])mkx[x[i]]=++tx;
		if(!mky[y[i]])mky[y[i]]=++ty;
	}
	for(int i=1; i<=n; i++) {
		int a=mkx[x[i]];
		int b=mky[y[i]]+tx;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	for(int i=1; i<=tx+ty; i++) {
		if(!mark[i]) {
			L=0,R=0,E=0;
			dfs(i);
			if(L<2||R<2)continue;
			E/=2;
			ans+=1LL*L*R-E;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 40448
#include<stdio.h>
#define MAX 100
#define WHITE  0
#define GRAY  1
#define BLACK  2

void DFS(int);
void DFS_init();

int n, G[MAX][MAX];
int color[MAX],X[MAX],Y[MAX], count;

int main(){
  int a,b,c,i,j;

  scanf("%d", &n);

  for ( i = 0; i<n; i++ ){
    for ( j = 0; j <n; j++ ){
      G[i][j]=0;
  }
  }
  for ( i = 0; i < n; i++ ){
    scanf("%d%d", &a, &b);
    a--;
    for ( j = 0; j < b; j++ ){
      scanf("%d", &c);
      c--;
      G[a][c]=1;
    }
  }
  
  DFS_init();
   for ( i = 0; i < n; i++ ){
    printf("%d %d %d\n", i+1, X[i], Y[i]);
  }
  return 0;
}

void DFS(int u){
  int i;
  color[u]=GRAY;
  count++;
  X[u]=count;
  for (i=0;i<n;i++){
    if (G[u][i]==0)continue;
    if(color[i]==WHITE){
      DFS(i);
    }
  }
  color[u]=BLACK;
  count++;
  Y[u] =count;
}

void DFS_init(){
  int  i;
  for (i=0;i<n;i++){
    color[i]=WHITE;
  }
  count=0;
   for (i=0;i<n;i++){
     if(color[i]==WHITE){
      DFS(i);
     }
   }
}



Measured memory_bytes: 2064
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int n;
int f[105][15];
int p[105][15];
LL ans = -11410065407;
vector<int> bitcheck;
/**********************************************/

void sol(){
    LL sum = 0;
    for(int i = 0; i < n; i++){
        int cnt = 0;
        for(int j = 0; j < 10; j++){
        //    cout << "i: " << i << " j: " << j << endl;
            if(bitcheck[j] == 1 && f[i][j] == 1){
                cnt++;
            }
        }
        sum += p[i][cnt];
        //cout << "sum: " << sum << endl;
    }
    ans = max(sum, ans);
    return;
}

void dfs(int num){
    if(num == 10){
        sol();
        return;
    }

    if(num == 9){
        REP(i, 10){
            if(bitcheck[i] == 1){
                bitcheck[num] = 0;
                dfs(num+1);
                bitcheck[num] = 1;
                dfs(num+1);
                break;
            }else if(i == 9){
                bitcheck[i] = 1;
                dfs(num+1);
            }
        }
    }else{
        bitcheck[num] = 0;
        dfs(num+1);
        bitcheck[num] = 1;
        dfs(num+1);
    }
}

int main(){
    cin >> n;
    REP(i, n){
        REP(j, 10){
            cin >> f[i][j];
        }
    }

    REP(i, n){
        REP(j, 11){
            cin >> p[i][j];
        }
    }
    bitcheck.resize(15);
    REP(i, 10){
        bitcheck[i] = 0;
    }
    dfs(0);
    cout << ans << endl;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
typedef long long ll;
typedef long double  ld;
#define pii pair<ll,ll> 
#define pic pair<ll,char>
#define vi vector< ll > 
#define vvi vector< vi > 
#define vpi vector< pii > 
#define vvpi vector< vpi > 
#define st  set <ll, greater <ll> >
#define mst  multiset <ll, greater <ll> >
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mapp  unordered_map <ll, ll>
#define ppii pair< pii, pii > 
#define test(t) ll t;cin>>t;while(t--)
#define inarr(n) ll arr[n];for(ll i=0;i<n;i++)cin>>arr[i];
#define ingra(m) vvi arr(100005);for(ll i=0;i<m;i++){ll u,v;cin>>u>>v;arr[u].pb(v);arr[v].pb(u);}
#define mem(a,b) memset(a,b,sizeof(a))
#define inn freopen("input.txt", "r", stdin)
#define outt freopen("output.txt", "w", stdout)
#define all(arr) arr.begin(),arr.end()
ll power(ll x,ll y){ll res = 1;while(y){if(y&1) res = (res*x)%mod;y=y/2,x=(x*x)%mod;}return res%mod;}
ll dp[1001][1001];
signed main()
{
    fast;
    ll h,w;
    cin>>h>>w;
    char arr[h+5][w+5];
    ll i,j;
    for(i=0;i<h;i++)
        for(j=0;j<w;j++)
            cin>>arr[i][j];
    dp[0][0] = 1;
    for(i=1;i<w;i++)
    {
        if(arr[0][i]=='.')
            dp[0][i] = 1;
        else
            break;
    }
    for(i=1;i<h;i++)
    {
        if(arr[i][0]=='.')
            dp[i][0] = 1;
        else
            break;
    }
    for(i=1;i<h;i++)
    {
        for(j=1;j<w;j++)
        {
            if(arr[i][j]=='.')
                dp[i][j] = dp[i-1][j]+dp[i][j-1];
            dp[i][j]%=mod;
        }
    }
    cout<<dp[h-1][w-1];
}

Measured memory_bytes: 9088
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 n = scanner.nextInt();
		while (n-- > 0) {
			int num = Integer.MAX_VALUE;
			int num2 = (1 << 8) - 1;
			long s = Long.parseLong(scanner.next(), 16);
			int x = (int) (s & num) >> 7;
			double y = (s & num2) * Math.pow(2, -7);
			String a = String.valueOf(y).substring(2);
			if (s >Integer.MAX_VALUE)
				System.out.print("-");
			System.out.printf("%d.%s\n", x, a);
		}
	}
}

Measured memory_bytes: 49496
#include <iostream>
#include <cstdio>
#include <map>

using namespace std;

int main() {
  int N; cin >> N;
  for (int i = 0; i < N; i++) {
    map<int, char> m;
    int start = 0;
    int end = 0;
    int pos = 0;
    string train;
    cin >> train;
    m[0] = train[0];
    for (unsigned int i = 1; i < train.size(); i+=3) {
      char c = train[i+2];
      if (train[i+1] == '>') pos++;
      else pos--;
      m[pos] = c;
      if (pos < start) start = pos;
      if (end < pos) end = pos;
    }
    for (int i = start; i <= end; i++) {
      cout << m[i];
    }
    cout << endl;
  }


  return 0;
}

Measured memory_bytes: 0
function main(input) {
    const args = input.split(' ');
    const a = parseInt(args[0], 10);
    const b = parseInt(args[1], 10);
  
  	if((a*b)%2==0){
    	console.log("Even");
    }else{
    	console.log("Odd");
    }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7496
#include <iostream>
using namespace std;
int main(void){
    int n,m,l;
    
    cin>>n>>m>>l;
    int a[n][m], b[m][l];
    long int c[n][l];
    
    for(int i=0; i<n; i++){
        for(int j=0; j<l; j++){
            c[i][j]=0;
        }
    }
    
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin>>a[i][j];
        }
    }
    for(int i=0; i<m; i++){
        for(int j=0; j<l; j++){
            cin>>b[i][j];
        }
    }
    
    for(int i=0; i<n; i++){
        for(int j=0; j<l; j++){
            for(int k=0; k<m; k++){
                c[i][j]+=a[i][k]*b[k][j];
            }
        }
    }
    
    for(int i=0; i<n; i++){
        for(int j=0; j<l-1; j++){
            cout<<c[i][j]<<" ";
        }
        cout<<c[i][l-1]<<endl;
    }
}



Measured memory_bytes: 3228
#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()
using namespace std;
typedef long long ll;

void Main()
{
    int n;
    cin >> n;

    cout << n*n*n << endl;
}

int main()
{
    std::cout << std::fixed << std::setprecision(15);
    Main();
}


Measured memory_bytes: 3056
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func rScan() []rune {
	return []rune(Scan())
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func mod(x, d int) int {
	x %= d
	if x < 0 {
		x += d
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func fSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}
func bPrint(f bool, x string, y string) {
	if f {
		fmt.Println(x)
	} else {
		fmt.Println(y)
	}
}
func iSSPrint(x []int) {
	fmt.Println(strings.Trim(fmt.Sprint(x), "[]"))
}

var lp1 int = 1000000007
var lp2 int = 998244353

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, lp1)
	sc.Split(bufio.ScanWords)
	s := iScan()
	f := make([]int, 10000)
	inv := make([]int, 10000)
	f[0], inv[0] = 1, 1
	for i := 1; i < 10000; i++ {
		f[i] = f[i-1] * i % lp1
		inv[i] = modinv(f[i], lp1)
	}
	ans := 0
	for i := s / 3; i >= 1; i-- {
		x := s - i*3
		ans += f[x+i-1] * inv[x] % lp1 * inv[i-1] % lp1
		ans %= lp1
	}
	fmt.Println(ans)
}
func modinv(a, m int) int {
	b, u, v := m, 1, 0
	for {
		t := a / b
		a -= t * b
		u -= t * v
		a, b, u, v = b, a, v, u
		if b == 0 {
			break
		}
	}
	u %= m
	if u < 0 {
		u += m
	}
	return u
}


Measured memory_bytes: 1940
str_1=input()
q=int(input())
for _ in range(q):
   lst=list(input().split())
   res = (lst[0])
   a = int(lst[1])
   b = int(lst[2])+1
  
   if res=='print':
     print(str_1[a:b])
   elif res=='replace':
    str_1=str_1[:a]+lst[3]+str_1[b:]
   elif res=='reverse':
    str_1=str_1[:a] + str_1[a:b][::-1] + str_1[b:]

Measured memory_bytes: 7672
#include <bits/stdc++.h>
  #include <cstdio>
  #include <cstring>
  #include <cmath>
  #include <cstring>
  #include <chrono>
  #include <complex>
  #define endl "\n"
  #define ll long long int
  #define vi vector<int>
  #define vll vector<ll>
  #define vvi vector < vi >
  #define pii pair<int,int>
  #define pll pair<long long, long long>
  #define mod 1000000007
  #define inf 1000000000000000001;
  #define all(c) c.begin(),c.end()
  #define mp(x,y) make_pair(x,y)
  #define mem(a,val) memset(a,val,sizeof(a))
  #define eb emplace_back
  #define f first
  #define s second
  
  using namespace std;
  int main()
  {
    std::ios::sync_with_stdio(false);
    int T;
   // cin>>T;
    T=1;
    // cin.ignore(); must be there when using getline(cin, s)
    while(T--)
    {
      ll a,b;
      cin>>a>>b;
      ll area=a*b;
      ll r=a+b-1;
      cout<<area-r;
    }
    return 0;
  }


Measured memory_bytes: 256
#include <stdio.h>

int main(){
   int h, w, m, n;
   scanf("%d %d", &h, &w);

   while( h != 0 | w != 0){
      for(m = 1;m <= h;m++){
      /* for the first line and last line */
         if(m == 1 || m == h){
            for(n=1;n<=w;n++){
               printf("#");
            }
            printf("\n");
         }

      /* for the other case */
         if(m != 1 && m != h){
            for(n=1;n<=w;n++){
               if(n == 1 || n == w){
                  printf("#");
               } else {
                    printf(".");
                 }
            }
            printf("\n");
          }
      }
      printf("\n");
      scanf("%d %d", &h, &w);
   }
   return 0;
}

Measured memory_bytes: 1804
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  ll n,k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n){
    int ai;
    cin >> ai;
    a[i] = ai-1;
  }
  if(k<=n){
    int p = 0;
    rep(i,k) p=a[p];
    cout << (p+1) << endl;
    return 0;
  }

  int p = a[0];
  ll c = 1;
  vector<int> f(n);
  while(p!=0&&f[p]==0){
    f[p] = c++;
    p = a[p];
  }
  k -= f[p];
  k %= c-f[p];
  rep(i,k) p=a[p];
  cout << (p+1) << endl;
}

Measured memory_bytes: 4844
H, W = map(int, input().split())
maze = [list(input()) for _ in range(H)]

cnt = [[0 for i in range(W)] for j in range(H)]

# 横
for i in range(H):
    done = [0] * W
    for j in range(W):
        if done[j]:
            continue
        if maze[i][j] == "#":
            continue
        l = 0
        while j + l < W:
            if maze[i][j+l] == "#":
                break
            l += 1
        for k in range(j,j+l):
            done[k] = 1
            cnt[i][k] += l





# 縦
for i in range(W):
    done = [0] * H
    for j in range(H):
        if done[j]:
            continue
        if maze[j][i] == "#":
            continue
        l = 0
        while j + l < H:
            if maze[j+l][i] == "#":
                break
            l += 1
        for k in range(j,j+l):
            done[k] = 1
            cnt[k][i] += l

ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, cnt[i][j]-1)
print(ans)

Measured memory_bytes: 260748
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <vector>

using namespace std;

typedef long long LL;
static const LL MOD = 1000000007LL;

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	string s;
	cin >> s;
	LL cnt[26] = {};
	for (int i = 0; i < n; ++i) {
		cnt[s[i] - 'a'] += 1;
	}
	LL ans = 1;
	for (int i = 0; i < 26; ++i) {
		ans = (ans * (cnt[i] + 1)) % MOD;
	}
	ans = (ans - 1 + MOD) % MOD;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <inttypes.h>
#include <algorithm>

using namespace std;

int main() {
    cin.sync_with_stdio(false);

    int n, grams;
    cin >> n >> grams;

    int minimal = INT32_MAX;
    int total_grams = 0;
    for (int i = 0; i < n; i++) {
        int m;
        cin >> m;
        minimal = min(minimal, m);
        total_grams += m;
    }

    cout << (n + (grams - total_grams) / minimal) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		double n = scan.nextInt();
		int total_x = 0;
		int x[] = new int[(int)n];
		for(int i=0;i<n;i++) {
			x[i] = scan.nextInt();
			total_x += x[i];
		}
		
		int ave_x = (int)Math.round(total_x/n);
		int ans = 0;
		for(int i=0;i<n;i++) {
			ans += Math.pow(x[i]-ave_x, 2);
		}
		System.out.println(ans);
		
	}
}




Measured memory_bytes: 23252
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	if(a <= 9 && b <= 9){
		cout << a*b << endl;
	}else{
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

vector<pair<long long, long long>> prime_factorize(long long N) {
	vector<pair<long long, long long> > res;
	for (long long a = 2; a * a <= N; ++a) {
		if (N % a != 0) continue;
		long long ex = 0;
		while (N % a == 0) {
			++ex;
			N /= a;
		}
		res.push_back({ a, ex });
	}
	if (N != 1) res.push_back({ N, 1 });
	return res;
}

int main()
{
	int n;
	cin >> n;
	vector<ll> al(n);
	vector<ll> cop(1000001);
	rep(j, n) {
		cin >> al[j];
		vector<pair<ll, ll>> res = prime_factorize(al[j]);
		rep(i, res.size()) {
			++cop[res[i].first];
		}
	}
	string ans = "pairwise coprime";
	rep(i, 1000000) {
		if (i <= 1) {
			continue;
		}
		if (cop[i] == n) {
			ans = "not coprime";
			break;
		}
		else if (cop[i] >= 2) {
			ans = "setwise coprime";
		}
	}
	cout << ans << endl;
	system("pause");
}




Measured memory_bytes: 18836
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const int INF = 1e9 + 10;

int main()
{
    int n;
    cin >> n;
    vector<int> vec(n);
    rep(i,n) cin >> vec[i];
    sort( vec.begin(), vec.end() );
    int count = 0;
    rep(i,n) rep(j,i) rep(k,j) {
        if (vec[i] != vec[j] && vec[j] != vec[k] && vec[k] + vec[j] > vec[i]) count++;
    }
    cout << count << endl;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

template<class T>inline bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int H, W, M;
    cin >> H >> W >> M;
    vector<pair<int, int>> bomb(M);
    for (int i=0; i<M; ++i) cin >> bomb[i].first >> bomb[i].second;

    for (auto &p : bomb) {
        --p.first;
        --p.second;
    }
    vector<int> cnth(H), cntw(W);
    int maxh = 0, maxw = 0;
    for (auto p : bomb) {
        ++cnth[p.first];
        ++cntw[p.second];
        chmax(maxh, cnth[p.first]);
        chmax(maxw, cntw[p.second]);
    }
    ll cntmh = 0, cntmw = 0;
    for (int x : cnth) if (x == maxh) ++cntmh;
    for (int x : cntw) if (x == maxw) ++cntmw;
    ll out = 0;
    for (auto p : bomb) if (cnth[p.first] == maxh && cntw[p.second] == maxw) ++out;
    if (out < cntmh * cntmw) cout << maxh + maxw << '\n';
    else cout << maxh + maxw - 1 << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 7920
#include "bits/stdc++.h"

using namespace std;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;

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

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N), D(N);
    ll sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }
    if (sum % ((N + 1) * N / 2) != 0) {
        cout << "NO" << endl;
        return 0;
    }
    ll k = sum / ((N + 1) * N / 2);

    ll s = 0;
    for (int i = 0; i < N; i++) {
        D[i] = A[(i + 1) % N] - A[i];
        if (D[i] - k > 0 || -(D[i] - k) % N != 0 || -(D[i] - k) / N > k) {
            cout << "NO" << endl;
            return 0;
        }
        s += -(D[i] - k) / N;
    }
    if (s != k) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }
    return 0;
}


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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio
    st s [3] ;
    loopcin(3 , s) ;
    for (lli i = 0 ; i < 3 ; i ++)
    {
        s[i][0] -= 32 ;
        cout << s[i][0] ;
    }

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import heapq
input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7

n=int(input())
G=[[] for i in range(n)]
for _ in range(n):
    inp = list(map(int,input().split()))
    u,k=inp[:2]
    for i in range(k):
        G[u].append((inp[2+2*i],inp[3+2*i]))

def disktra(g,s):
    n=len(g)
    dist = [inf]*n
    dist[s] = 0
    hq=[]
    heapq.heappush(hq,(dist[s],s))
    while hq:
        cost,u =heapq.heappop(hq)
        if dist[u] < cost:
            continue
        for v,c in g[u]:
            if dist[v] <= dist[u] +c:
                continue
            dist[v] = dist[u] + c
            heapq.heappush(hq,(dist[v],v))
    return dist

d=disktra(G,0)
for i in range(n):
    print(i,d[i])


Measured memory_bytes: 68980
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {

	static class Pair {
		public int x, y, id;
		public Pair() {
			x = y = 0;
		}
		public Pair(int x, int y, int i) {
			this.x = x;
			this.y = y;
			id = i;
		}
	}
	
	public static void main(String[] args) throws IOException {

		InputReader in = new InputReader(System.in);
		PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		int n = in.nextInt();
		String s;
		Map<String,Integer> mp=new HashMap<>();
		int y = 0;
		Vector<String>ans=new Vector<String>();
		for(int i=0;i<n;i++) {
			s = in.next();
		    if(mp.containsKey(s)) {
		    	int x = mp.get(s) + 1;
		    	mp.put(s,x);
		    	if(x>y) {
		    		ans.clear();
		    		ans.add(s);
		    		y=x;
		    	}
		    	else if(x==y) {
		    		ans.add(s);
		    	}
		    }else {
		    	mp.put(s,1);
		    	if(1>y) {
		    		y = 1;
		    		ans.add(s);
		    	}else if(1==y) {
		    		ans.add(s);
		    	}
		    }
		}
		Collections.sort(ans);
		for(String _s: ans) {
			out.println(_s);
		}
		out.flush();

	}

	static class InputReader {
		StreamTokenizer tokenizer;

		public InputReader(InputStream stream) {
			tokenizer = new StreamTokenizer(new BufferedReader(new InputStreamReader(stream)));
			tokenizer.ordinaryChars(33, 126);
			tokenizer.wordChars(33, 126);
		}

		public String next() throws IOException {
			tokenizer.nextToken();
			return tokenizer.sval;
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public boolean hasNext() throws IOException {
			int res = tokenizer.nextToken();
			tokenizer.pushBack();
			return res != StreamTokenizer.TT_EOF;
		}
	}

}


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

string a;
int main()
{
	int i;
	cin >> a;
	for (i = 0; i < a.size(); i++) {
		if (i % 2 && a[i] != 'i') break;
		else if (i % 2 == 0 && a[i] != 'h') break;
	}
	if (a.size() % 2 == 1 || i < a.size()) puts("No");
    else puts("Yes");
    return 0;
}

Measured memory_bytes: 256
import sys
A=[35.5,37.5,40,43,50,55,70,1e6]
B=[71,77,83,89,105,116,148,1e6]
C=["AAA","AA","A","B","C","D","E","NA"]
def f(t,X):
  i=0
  for e in X:
    if t<e: break
    i+=1
  return i
for s in sys.stdin:
  t1,t2=map(float,s.split(" "))
  x=max(f(t1,A),f(t2,B))
  print C[x]

Measured memory_bytes: 4244
/*
貪欲
後ろから見る
DP
順位表をチェック



*/
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<set>
#include<tuple>
using namespace std;
#define INF 3e18+7
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,ll>,ll> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);


int main(){
    int x,y;
    cin>>x>>y;
    if(x==1 && y==1){
        cout<<1000000<<endl;
        return 0;
    }
    ll ans=0;
    if(x==1) ans+=300000;
    else if(x==2) ans+=200000;
    else if(x==3) ans+=100000;
    
    if(y==1) ans+=300000;
    else if(y==2) ans+=200000;
    else if(y==3) ans+=100000;
    cout<<ans<<endl;
}


Measured memory_bytes: 256