akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
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 f(ll X) {
  if (X < 0) return 0;
  if (X % 4 == 0) return X;
  else if (X % 4 == 2) return (X ^ 1);
  else if (X % 4 == 1) return 1;
  else return 0; 
}

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); //入出力高速化
  ll A,B; cin >> A >> B;
  cout << (f(A-1) ^ f(B)) << endl;
}

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

constexpr ll mod_value = (1e9 + 7);

vector<int> sieve(int v)
{
	vector<int> p(v + 1, 0);
	p[0] = -1;
	p[1] = -1;

	int sqrt_v = ceil(sqrt(v));
	for (int i = 2; i <= sqrt_v; ++i)
	{
		if (p[i]) continue;

		for (int j = i * i; j <= v; j += i)
		{
			if(!p[j]) p[j] = i;
		}
	}

	return p;
}

long long modinv(long long a, long long m)
{
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

long long moddivision(long long numerator, long long denominator, long long modvalue)
{
	return numerator * modinv(denominator, modvalue);
}

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

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

	auto p = sieve(1e6);

	map<int, int> m;
	for (int i = 0; i < n; ++i)
	{
		map<int, int> m2;
		int rest = a[i];
		while (rest > 1)
		{
			if (p[rest])
			{
				++m2[p[rest]];
				rest /= p[rest];
			}
			else
			{
				++m2[rest];
				rest /= rest;
			}
		}
		for (auto pair : m2)
		{
			m[pair.first] = max(m[pair.first], pair.second);
		}
	}

	unsigned long long lcm = 1;
	for (auto pair : m)
	{
		lcm = lcm * pow(pair.first, pair.second);
		lcm %= mod_value;
	}

	ll ans = 0;
	for (int i = 0; i < n; ++i)
	{
		ans += moddivision(lcm, a[i], mod_value);
		ans %= mod_value;
	}

	cout << ans % mod_value;

}


Measured memory_bytes: 4608
N, M = map(int, input().split())
MOD = 10 ** 9 + 7

# 階乗
factorial = [1]
for i in range(1, M + 1):
    factorial.append(factorial[-1] * i % MOD)
inv_factorial = [-1] * (M + 1)
inv_factorial[-1] = pow(factorial[-1], MOD - 2, MOD)
for i in reversed(range(M)):
    inv_factorial[i] = inv_factorial[i + 1] * (i + 1) % MOD

ans = 0
for k in range(N + 1):
    ans += (
        factorial[N]
        * inv_factorial[k]
        * inv_factorial[N - k]
        * (-1) ** (k % 2)
        * factorial[M]
        * inv_factorial[M - k]
        * pow(factorial[M - k] * inv_factorial[M - N], 2, MOD)
    )
    ans %= MOD

print(ans)

Measured memory_bytes: 113688
#include <iostream>
#include <set>
#include <cmath>
using namespace std;
int main(){
    int N;
    cin >> N;
    int A[N];
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    set<int> X;
    set<int> d;


    for(int i=0;i<N;i++){
        int a=A[i];
        if(X.find(a) != X.end()) d.insert(a);
        X.insert(a);
    }
    int ans=0;

    for(int i=0;i<N;i++){
        int a=A[i];
        X.erase(a);
        bool exist = false;
        for(int j=1;j<sqrt(a)+1;j++){
            if(a%j==0){
                if(d.find(j)!=d.end() || X.find(j)!=X.end()){
                    exist=true;
                    break;
                }
                if(d.find(a/j)!=d.end() || X.find(a/j)!=X.end()){
                    exist=true;
                    break;
                }
            }
        }
        if(exist == false) ans+=1;
        X.insert(a);
    }
    cout << ans <<endl;
    return 0;
}

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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef string str;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

int main() {
    int n;
    cin >> n;
    vi a(n);
    REP(i, n) {
        cin >> a[i];
    }
    sort(ALL(a), greater<int>());
    int as = 0, bs = 0;
    REP(i, n) {
        if(i % 2 == 0) {
            as += a[i];
        }
        else bs += a[i];
    }
    cout << as - bs << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int A, B;
    scanf("%d%d",&A, &B);
    if(A+B>=A-B&&A+B>=A*B)
    {
        printf("%d",A+B);
    }
    else if(A-B>=A+B&&A-B>=A*B)
    {
        printf("%d",A-B);
    }
    else if(A*B>=A+B&&A*B>=A-B)
    {
        printf("%d",A*B);
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n,p;
    cin>>n;
    p=n%10;
    if(p==3)
        cout<<"bon"<<endl;
    else if(p==0 || p==1 || p==6 || p==8)
        cout<<"pon"<<endl;
    else
        cout<<"hon"<<endl;
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
#define Pll pair<ll,ll>

template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<"\n";}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const long MOD =1e+9+7;
#define PI 3.14159265258979

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

int main(void){
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	
	ll N,M;
	cin>>N>>M;
	print(abs((N*M)-(2*N)-(2*(M-2))));
	return 0;
}




Measured memory_bytes: 256
judge = {'AC' : 0, 'WA' : 0, 'TLE' : 0, 'RE' : 0}
N = int(input())

for i in range(N):
    testcase = input()
    if testcase == 'AC':
        judge['AC'] += 1
    elif testcase == 'WA':
        judge['WA'] += 1
    elif testcase == 'TLE':
        judge['TLE'] += 1
    else:
        judge['RE'] += 1

print('AC x ' + str(judge['AC']))
print('WA x ' + str(judge['WA']))
print('TLE x ' + str(judge['TLE']))
print('RE x ' + str(judge['RE']))


Measured memory_bytes: 9128
//
// Created by yamunaku on 2019/08/30.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

struct UnionFind{
    vi node;

    UnionFind(int sz){
        node = vi(sz);
        iota(all(node), 0);
    }

    int root(int x){
        if(node[x] == x) return x;
        return node[x] = root(node[x]);
    }

    bool uni(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y)return false;
        node[x] = y;
        return true;
    }
};

int n;
vector<double> x, y, a;

double dist(int p, int q){
    return sqrt((x[p] - x[q]) * (x[p] - x[q]) + (y[p] - y[q]) * (y[p] - y[q]));
}

double solve(int f){
    double total = 0;
    vector<int> idx;
    vector<pair<double, pair<int, int>>> edge;
    rep(i, n){
        if(f & (1 << i)){
            idx.push_back(i);
        }
    }
    int sz = idx.size();
    rep(i, sz){
        total += a[idx[i]];
        rep(j, i){
            edge.push_back({dist(idx[i], idx[j]), {i, j}});
        }
    }
    sort(all(edge));
    UnionFind uf(sz);
    double cost = 0;
    rep(i, edge.size()){
        if(uf.uni(edge[i].second.first, edge[i].second.second)) cost += edge[i].first;
    }
    return max(0.0, total - cost) / (double)sz;
}

int main(){
    cin >> n;
    x = vector<double>(n);
    y = vector<double>(n);
    a = vector<double>(n);
    rep(i, n) cin >> x[i] >> y[i] >> a[i];
    vector<double> dp(1 << n, 0);
    dp[0] = IINF;
    CST(10);
    vector<double> ans(1 << n, IINF);
    repl(i, 1, 1 << n) ans[i] = solve(i);
    repl(i, 1, 1 << n){
        vector<int> b;
        rep(j, n) if(i & (1 << j)) b.push_back(j);
        int s = b.size();
        repl(j, 1, (1 << s)){
            int ad = 0;
            rep(k, s) if(j & (1 << k)) ad |= (1 << b[k]);
            dp[i] = max(dp[i], min(dp[i ^ ad], ans[ad]));
        }
    }
    cout << dp[(1 << n) - 1] << endl;
    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main(){
  int min=1000,count=0;
  string S,T;
  cin>>S>>T;
  for(int i=0;i<S.size()-T.size()+1;i++){
    for(int u=0;u<T.size();u++){
      if(S[u+i]!=T[u]){
        count++;
      }
    }
    //cout<<count<<endl;
    if(min>=count) min=count;
    count=0;
  }
  cout<<min<<endl;
  }
  

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

int main()
{
    int n, m;
    cin >> n >> m; 
    int a[n][m], b[m];
    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++){
        cin >> b[i];
    }

    for(int i = 0; i < n; i++){
        long c = 0;
        for(int j = 0; j < m; j++){
            c += a[i][j] * b[j];
        }
        cout << c << endl;
    }
    return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define MAXN 200005
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(c) (c).begin(), (c).end()
#define KONJ 42-42
using namespace std;

int n;

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	cin >> n;
	if (n == 1) cout << 1;
	else if (not(n % 2)) cout << 0.5;
	else cout << (float)(n / 2 + 1) / n;
	return 0;
}


Measured memory_bytes: 256
eval'N,K,*A='+`dd`.split*?,
A.sort!
b=s=K%2<1?1:A.pop
(K/2).times{s*=(A[0]*A[1]*b>b*A[-1]*A[-2]?A.shift(2):A.pop(2)).reduce:*
s%=10**9+7}
p s

Measured memory_bytes: 54812
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i = 0;i < n; i++)
#define REP(i,n) for(int i = 1;i <= n; i++)
// ----GCC ONLY---- //
#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// ----        ---- //
#define ll long long
#define MOD 10000007
#define PB push_back


using namespace std;

int main(){

    int k,x;
    cin >> k >> x;

    int ans = k * 500;

    if(ans >= x){
        puts("Yes");
    }else{
        puts("No");
    }
    return 0;

}




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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAX = 100010;
int n, m;

int main()
{
//    int T;
//    int x, y, z;
//    scanf("%d",&T);
//    while(T--)
//    {
//
//    }
//printf("%d",'A'-'a');
    string x, y, z;
    cin >> x >> y >> z;
    printf("%c%c%c\n",x[0]-32,y[0]-32,z[0]-32);
    return 0;
}


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

using namespace std;
typedef long long ll;

int n;
const int N=(1<<18);
const int M=100000;
vector<int> val(N,0);
vector<int> w(N,0);
vector<int> depth(N,0);
vector<vector<int>> dp((1<<9),vector<int>(M+1,0));

void dfs(int a)
{
    depth[a]=depth[a/2]+1;
    if(depth[a]<=9)
    {
        dp[a]=dp[a/2];
        for(int i=M-w[a];i>=0;i--) dp[a][i+w[a]]=max(dp[a][i+w[a]],dp[a][i]+val[a]);
        for(int i=1;i<=M;i++) dp[a][i]=max(dp[a][i],dp[a][i-1]);
    }
    if(2*a<=n) dfs(2*a);
    if(2*a+1<=n) dfs(2*a+1);
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for(int i=1;i<=n;i++) cin >> val[i] >> w[i];
    dfs(1);
    int q;
    cin >> q;
    while(q--)
    {
        int a,l;
        cin >> a >> l;
        vector<array<int,2>> v;
        while(depth[a]>9)
        {
            v.push_back({val[a],w[a]});
            a/=2;
        }
        int res=dp[a][l];
        int sz=v.size();
        for(int mask=1;mask<(1<<sz);mask++)
        {
            int one=0;
            int two=0;
            for(int i=0;i<sz;i++)
            {
                if(mask&(1<<i))
                {
                    one+=v[i][0];
                    two+=v[i][1];
                }
            }
            if(two<=l) res=max(res,one+dp[a][l-two]);
        }
        cout << res << "\n";
    }
    return 0;
}


Measured memory_bytes: 207140
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,L;
  cin >> N >> L;
  string s;
  vector<string> S(N);
  for (int i = 0; i < N; i++){
    cin >> s;
    S[i] = s;
  }
  sort(S.begin(),S.end());
  for (int i = 0; i < N; i++){
    cout << S[i];
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 1111116
#define K 6666
#define mod 1000000007

int n,a[N],b[N],e[N],f[K][K],ans;

long long inv(long long x){
	long long t=1;
	for (int k=mod-2;k;k/=2,x=x*x%mod)
		if (k%2) t=t*x%mod;
	return t;
}

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-')  f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();
	for (int i=1;i<=n;i++){
		a[i]=read();b[i]=read();
		f[3000-a[i]][3000-b[i]]++;
	}
	for (int i=1;i<K;i++)
		for (int j=1;j<K;j++)
			f[i][j]=(f[i][j]+f[i-1][j]+f[i][j-1])%mod;
	for (int i=1;i<=n;i++)
		ans=(ans+f[3000+a[i]][3000+b[i]])%mod;
	for (int i=e[0]=1;i<N;i++)
		e[i]=1ll*e[i-1]*i%mod;
	for (int i=1;i<=n;i++)
		ans=(ans-e[2*a[i]+2*b[i]]*inv(e[2*a[i]])%mod*inv(e[2*b[i]])%mod+mod)%mod;
	printf("%lld\n",ans*inv(2)%mod);
	return 0;
}

Measured memory_bytes: 184704
#include<algorithm>

template<class T>
int partition(T &A, int first, int last){
    const int pivot = A[last-1];
    int bound = first-1;
    for(int i=first;i<last;++i)
        if(A[i]<=pivot) std::swap(A[++bound], A[i]);
    return bound;
}

#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    vector<int> P(N);
    for(int i=0;i<N;++i) cin>>P[i];
    int bound = partition(P,0,N);
    string s;
    for(int i=0;i<N;++i){
        if(i==bound) s+='['+to_string(P[i])+"] ";
        else s+=to_string(P[i])+' ';
    }
    s.pop_back();
    cout<<s<<endl;
}

Measured memory_bytes: 4020
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	as := make([]int, n)
	for i := range as {
		fmt.Scan(&as[i])
	}
	sort.Ints(as)
	score := 0
	for i := 0; i < len(as); i++ {
		if i%2 == 0 {
			score += as[len(as)-1-i]
		} else {
			score -= as[len(as)-1-i]
		}
	}
	fmt.Println(score)
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int student[] = new int[N];
	
		for(int i= 1;i<N+1; ++i) {
			student[sc.nextInt()-1] = i ;
		}
		
		for(int j=0;j<N;++j) {
			System.out.print(student[j]+" ");
		}
	}	
}

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

const ll p = 1e9+7;
const int MAXN = 2e5+5;

int n, l, a[MAXN];

int main() {
	cin >> n >> l;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	int y = -1;
	for (int i = 0; i < n-1; ++i)
		if (a[i]+a[i+1] >= l)
			y = i;
	if (y == -1) { cout << "Impossible\n"; return 0; }
	y++;
	cout << "Possible\n";
	for (int i = 1; i < y; ++i)
		cout << i << "\n";
	for (int i = n-1; i >= y+1; --i)
		cout << i << "\n";
	cout << y << endl;
}

Measured memory_bytes: 1152
s=list(input())
t=list(input())

r=len(t)
for ii in range(len(s)-len(t)+1):
  rr=0
  for jj in range(len(t)):
    if s[ii+jj]!=t[jj]:
      rr+=1
  if rr<r:
    r=rr
print(r)

Measured memory_bytes: 9072
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll c=0,ans=0;
ll vis[200010];
vector<vector<int>>adj(200010);
void dfs(int v)
{
     vis[v]=1;
     c++;
     for(auto i=adj[v].begin();i!=adj[v].end();i++)
     {
         if(vis[*i]==0)
              dfs(*i);


     }
}
int main()
{
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll k,i;
        cin>>k;
        for(i=0;i<k;i++)
        {
            ll x,y;
            cin>>x>>y;
            adj[x].push_back(y);
            adj[y].push_back(x);
        }
        //ll vis[n+1];
        //memset(vis,false,sizeof(vis));
        for(i=1;i<=n;i++)
        {
            if(vis[i]==false)
                {
                    c=0;
                    dfs(i);

                 ans=max(ans,c);
                }
        }
        cout<<ans<<endl;
    }

}


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

int gcd(int a, int b) {
	return (b == 0 ? a : gcd(b, a % b));
}
int main() {
	int N, M;
	string A, B;
	cin >> N >> M >> A >> B;
	int GCD = gcd(N, M);
	long long LCM = (long long)N / GCD * M;
	bool ans = true;
	for (int i = 0; i < GCD; i++) if (A[i * N / GCD] != B[i * M / GCD]) ans = false;
	cout << (ans ? LCM : -1) << endl;
}


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

int main(){
  char t[1000],h[1000];
  int n,p[2]={0,0},i;

  scanf("%d",&n);

  for(i=0; i<n; ++i){
    scanf("%s%s",t,h);
    if(strcmp(t,h)==0){
      p[0] += 1;
      p[1] += 1;
    }else if(strcmp(t,h) < 0)
      p[1] += 3;
    else
      p[0] += 3;
  }

  printf("%d %d\n",p[0],p[1]);


  return 0;
}



Measured memory_bytes: 2616
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if(a==b) {
			System.out.println("a == b");
		} else if (a>b) {
			System.out.println("a > b");
		} else {
			System.out.println("a < b");
		}

	}
}


Measured memory_bytes: 26320
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final int m = scanner.nextInt();

        final int[] array = new int[n + 1];
        for (int i = 0; i < m; i++) {
            array[scanner.nextInt()]++;
            array[scanner.nextInt()]++;
        }

        final boolean answer = Arrays.stream(array, 1, n + 1)
                .allMatch(i -> i % 2 == 0);
        System.out.println(answer ? "YES" : "NO");
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int mod = 1e9 + 7;
int n;
string s1, s2;
ll res;

int main() {
    cin >> n >> s1 >> s2;
    res = 1;
    int i = 0;
    int p = 0;
    while (i < n) {
        if (s1[i] == s2[i]) { // v
            ++i;
            if (p == 0) {
                res = 3;
            } else if (p == 1) { // v
                res = res * 2 % mod;
            } else if (p == 2) { // h
            }
            p = 1;
        } else { // h
            i += 2;
            if (p == 0) {
                res = 6;
            } else if (p == 2) {
                res = res * 3 % mod;
            } else if (p == 1) {
                res = res * 2 % mod;
            }
            p = 2;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3612
def main():
    n = int(input())
    S = input()
    a, b = 0, 0
    aa = 0
    m = 0
    for s in S:
        if aa > 0 and s == ')':
            m += 1
            aa -= 1
        if s == '(':
            a += 1
            aa += 1
        else:
            b += 1
    print(''.join(['(' * (b - m), S, ')' * (a - m)]))

if __name__ == '__main__':
    main()


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

const int N = 2005;
const int mod = 1e9 + 7;

int n, k;
int f[N][N];
int fac[N * N], ifac[N * N];

void add(int &x,int y) {
	x += y; if (x >= mod) x -= mod;
}

int mul(int x,int y) {
	return (long long) x * y % mod;
}

int pw(int x,int y) {
	int ret = 1;
	while (y) {
		if (y & 1) ret = mul(ret, x);
		x = mul(x, x);
		y >>= 1;
	}
	return ret;
}

int C(int n,int k) {
	if (n < k || k < 0) return 0;
	return mul(fac[n], mul(ifac[k], ifac[n - k]));
}

int main() {
	ios_base::sync_with_stdio(false);
	fac[0] = 1; 
	for (int i = 1; i < N * N; ++i) fac[i] = mul(fac[i - 1], i);
	ifac[N * N - 1] = pw(fac[N * N - 1], mod - 2);
	for (int i = N * N - 2; i >= 0; --i) ifac[i] = mul(ifac[i + 1], i + 1);
	cin >> n >> k;
	if (k == 1) return cout << 1 << '\n',0;
	
	f[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j <= i; ++j) {
			if (j < i) add(f[i][j], f[i - 1][j]);
			if (j > 0) add(f[i][j], mul(f[i][j - 1], C(n * k - i - (j - 1) * (k - 1) - 1, k - 2))); 
		}
	}
	cout << mul(f[n][n], fac[n]) << '\n';
}

Measured memory_bytes: 47360
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#define LL long long
#define mem(a , x) memset(a , x , sizeof(a))
using namespace std;
char mp[105][105];
vector<pair<int , int> >v1 , v2;
void print()
{
    for(int i = 1 ; i <= 98 ; i++){
        for(int j = 1 ; j <= 49 ; j++){
            printf("%c" , mp[i][j]);
        }
        puts("");
    }
}
int main()
{
    int black , white , flag = 0;
    scanf("%d %d" , &white , &black);
    for(int i = 1 ; i <= 100 ; i++){
        for(int j = 1 ; j <= 100 ; j++){
            mp[i][j] = '.';
        }
    }
    for(int i = 1 ; i <= 49 ; i++){
        for(int j = 1 ; j <= 49 ; j++){
            if(i % 2 || j % 2){
                mp[i][j] = '#';
            }
            else{
                mp[i][j] = '.';
            }
        }
    }
    for(int ii = 50 ; ii <= 98 ; ii++){
        for(int j = 1 ; j <= 49 ; j++){
            int i = ii - 49;
            if(i % 2 || j % 2){
                mp[ii][j] = '.';
            }
            else{
                mp[ii][j] = '#';
            }
        }
    }
    //print();
    for(int i = 2 ; i <= 49 ; i += 2){
        for(int j = 2 ; j <= 49 ; j+= 2){
            if(mp[i][j] == '.'){
                v1.push_back(make_pair(i , j));
            }
        }
    }
    for(int i = 51 ; i <= 98 ; i += 2){
        for(int j = 2 ; j <= 49 ; j+= 2){
            if(mp[i][j] == '#'){
                v2.push_back(make_pair(i , j));
            }
        }
    }
    int sz1 = v1.size() , sz2 = v2.size();
    int cnt1 = sz1 + 1 - white , cnt2 = sz2 + 1 - black;
    //printf("%d %d %d %d\n" , sz1 , cnt1 , sz2 , cnt2);
    puts("98 49");
    for(int i = 0 ; i < cnt1 ; i++){
        mp[v1[i].first][v1[i].second] = '#';
    }
    for(int i = 0 ; i < cnt2 ; i++){
        mp[v2[i].first][v2[i].second] = '.';
    }
    print();
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



int main () {
	SpeedForce;
	cin >> n >> m;
	For (i, 1, m) {
		int x;
		cin >> x;
		cur += x;
	}
	cout << max(-1, n-cur) << '\n';

	return Accepted;
}

// B...a

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  string S;
  cin >> S;
  ll N = S.size();
  int ans = 1e9;
  rep(i, N-2){
    ans = min(abs(stoi(S.substr(i, 3))-753), ans);
  }

  cout << ans;
  return 0;
}


Measured memory_bytes: 256
def slove():
    import sys
    input = sys.stdin.readline
    h, w = list(map(int, input().rstrip('\n').split()))
    s = [list(str(input().rstrip('\n'))) for _ in range(h)]
    u = [[0] * w for _ in range(h)]
    d = [[0] * w for _ in range(h)]
    l = [[0] * w for _ in range(h)]
    r = [[0] * w for _ in range(h)]
    for i in range(h):
        for j in range(w):

            if i == 0:
                u[i][j] += 1 if s[i][j] != "#" else 0
                d[-i-1][j] += 1 if s[-i-1][j] != "#" else 0
            else:
                u[i][j] += 1 + u[i-1][j] if s[i][j] != "#" else 0
                d[-i-1][j] += 1 + d[-i][j] if s[-i-1][j] != "#" else 0

            if j == 0:
                l[i][j] += 1 if s[i][j] != "#" else 0
                r[i][-j-1] += 1 if s[i][-j-1] != "#" else 0
            else:
                l[i][j] += 1 + l[i][j-1] if s[i][j] != "#" else 0
                r[i][-j-1] += 1 + r[i][-j] if s[i][-j-1] != "#" else 0

    mt = 0
    for i in range(h):
        for j in range(w):
            t = u[i][j] + d[i][j] + r[i][j] + l[i][j] - 3
            mt = max(mt, t)
    print(mt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 308616
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007 
#define all(n)      (n).begin(), (n).end()
#define ll long long 
#define PI 3.14159265358979323846



int main (){
	#ifndef ONLINE_JUDGE
		freopen ("input.txt","r",stdin);
		freopen ("output.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	//Write from here.
	int r; cin >> r; 
	long double ans;
	ans = (2 * PI * r);
	cout << setprecision(20) << ans << endl;
	
	
		
	
	return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const int INF = 1001001001;

int main(){
  int n; cin >> n;
  vector<int> x(n);
  rep(i, n) cin >> x[i];

  int mi = INF;
  REP(p, 1, 100){
    int sum = 0;
    rep(i, n){
      sum += (x[i]-p) * (x[i]-p);
    }
    chmin(mi, sum);
  }
  
  cout << mi << endl;

  return 0;
}


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

#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
void print_pair(pi a){
  cerr<<"("<<a.first<<", "<<a.second<<") ";
}
template<int T1, int T2>
void print_2d(int a[T1][T2]){
  For(i, T1){
    For(j, T2){
      cerr<<a[i][j]<<" ";
    }
    cerr<<endl;
  }
}

int N,C;
int D[30][30];
int c[500][500];
pair<ll,int> point[3][30];

int main(){
  cin>>N>>C;
  For(i,C)For(j,C){cin>>D[i][j];}
  For(i,N)For(j,N){cin>>c[i][j];c[i][j]--;}
  For(color,C){
    point[0][color].second=point[1][color].second=point[2][color].second=color;
    For(i,N)For(j,N){
      point[(i+j)%3][color].first+=D[c[i][j]][color];
    }
  }
  sort(point[0],point[0]+C);
  sort(point[1],point[1]+C);
  sort(point[2],point[2]+C);
  ll ans=LLONG_MAX;
  For(i,3)For(j,3)For(k,3){
    if(point[0][i].second!=point[1][j].second&&point[0][i].second!=point[2][k].second&&point[1][j].second!=point[2][k].second){
      ans=min(ans,point[0][i].first+point[1][j].first+point[2][k].first);
    }
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 1280
#include<iostream>
#include<cstdio>
#include <cstring>
#include<map>
#include<string>
#include<stack>
#include <algorithm>
#include <sstream>
#include<vector>
#include<map>
#include<cmath>
using namespace std;


int main(){
	float l,r;
	int ans_r[4]={0},ans_l[4]={0};
	while(cin>>l>>r)
	{
		
		if(1.1<=l) ans_l[0]++;
		else if(0.6<=l && l<1.1) ans_l[1]++;
		else if(0.2<=l && l<0.6) ans_l[2]++;
		else if(l < 0.2) ans_l[3]++;

		if(1.1<=r) ans_r[0]++;
		else if(0.6<=r && r<1.1) ans_r[1]++;
		else if(0.2<=r && r<0.6) ans_r[2]++;
		else if(r < 0.2) ans_r[3]++;
	}
	for(int i=0; i<4; i++)
	{
		cout<<ans_l[i]<<" "<<ans_r[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1224
f h w = (x*w-(h-x)`div`2*w) `min` (x*w-w`div`2*(h-x))
  where x = (h+2)`div`3
g h w = ((h-x+1)`div`2*w-x*w) `min` ((w+1)`div`2*(h-x)-x*w)
  where x = h`div`3
main = do
  [h,w] <- map read . words <$> getLine :: IO [Int]
  print $ f h w `min` f w h `min` g h w `min` g w h

Measured memory_bytes: 508
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(N, M, PY):
    ken = [0] * (N + 1)
    PY = [PY[i] + [i] for i in range(M)]
    PY.sort(key=lambda x: x[1])
    for i in range(M):
        p, y, s = PY[i]
        ken[p] += 1
        PY[i].append(ken[p])
    PY.sort(key=lambda x: x[2])
    for p, y, s, n in PY:
        print(('000000' + str(p))[-6:] + ('000000' + str(n))[-6:])


if __name__ == '__main__':
    N, M = map(int, input().split())
    PY = [[int(i) for i in input().split()] for _ in range(M)]
    solve(N, M, PY)

    # # test
    # from random import randint, sample
    # from func import random_str
    # N, M = 10 ** 5, 10 ** 5
    # PY = sample([[randint(1, 5), 10 ** 8 - i] for i in range(M)], M)
    # solve(N, M, PY)


Measured memory_bytes: 47632
/*Flamenco Sketches*/
#include<bits/stdc++.h>
using namespace std;
 
#define NL '\n'
#define xx first
#define yy second
#define ll long long
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define sz(x) x.size()
#define all(x) (x).begin(), (x).end()
#define mem(a, b) memset(a, b, sizeof(a))
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;++i)
#define async() ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
 
//#define FayeValentine 
void dbg(){cerr<<NL;}template<typename H,typename... T> void dbg(H h,T... t){cerr<<' '<<h;dbg(t... );}
#ifdef  FayeValentine
#define debug(...) cerr<<"("<<#__VA_ARGS__<<"):",dbg(__VA_ARGS__)
#else
#define debug(...) 
#endif


const int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997};


void absinthe() {
	int n, f = 1; cin >> n;
	const int MOD = 1e9+7;
	for(int i = 0; i < 168; i++) {
		if(primes[i] > n) break;
		ll p = primes[i], cnt = 0;
		while(p <= n){
			cnt += n/p;
			p *= primes[i];
		}
		f = ((f%MOD) * ((cnt+1)%MOD)) % MOD;
	}
	cout << f << NL;
}
 
 
int main(){
  //freopen("input.txt", "r", stdin);
  async();
  int __t = 1; //cin >> __t;
  for(int __c = 1; __c <=__t; __c++) {
    //cout << "Case #" << __c << ": "; 
    absinthe();
  }
}  

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

int main(void)
{
	long int i, j;
	long int n;
	long int ans = 0;
	
	scanf("%ld", &n);
	
	for(i = 1; i <= n; i++) {
		if((long int)floor((double)i * 1.08) == n) {
			printf("%ld\n", i);
			return 0;
		}
	}
	
	printf(":(\n");
	
	return 0;
}


Measured memory_bytes: 128
/*
AizuOnline A1160
How many islands
13/03/13 RUNTIME Error
13/03/16 WA
*/
#include <stdio.h>
#include <stdlib.h>

int width = 10;
int height = 10;

char kajuen[100][101];

char search_next(int * x,int * y)
{
  int i,j;
/* printf("SEARCH =%d %d\n",*x,*y); */
  i = *x;j = *y;
  goto START;
  for(i=0;i<height;i++)
    for(j=0;j<width;j++)
      {
      START:
	//	printf("SEARCH =%d %d:",i,j);
	if(kajuen[i][j]=='1')
	  { *x=i;*y=j;
	    return(kajuen[i][j]);
	  }
      }
  return(0);
}

void paint(int p,char f,int x,int y)
{
  int i,j;

#ifdef DEBUG2
  printf("P=%d %d %c %c",x,y,p,f);
  printf("F=%c N=%c %c %c\n",kajuen[x+1][y],kajuen[x][y+1],owner[x+1][y],owner[x][y+1]);
#endif
  //owner[x][y]=p+'A';
  kajuen[x][y]='0';
  for(i=x-1;i<=x+1;i++)
    for(j=y-1;j<=y+1;j++)
      if((i >=0) && (i <height) && (j >= 0) && (j <width) && !(x==i&&y==j))
	{
	  //printf("p:%d %d %d %d",x,y,i,j);
	if(kajuen[i][j] == f)
	  paint(p,f,i,j);
	}
}

int devide_kajuen()
{
  int x,y;
  int person;
  char f;

  
  x=0;y=0;
  person = 0;
  while(f=search_next(&x,&y) != 0)
    {   
      f = kajuen[x][y];
      paint(person,f,x,y);
      person ++;

    }
  return(person);
}
void clear_table()
{
  int i,j;
  for(i=0;i<100;i++)
      for(j=0;j<101;j++)
      {
        kajuen[i][j]='\0';
      }   
}
main()
{
  int n;
  int i,j;


  while(EOF != scanf("%d %d",&width,&height) && (width || height))
    {
      clear_table();
      for(i=0;i<height;i++)
	for(j=0;j<width;j++)
	  {  scanf(" %c",&(kajuen[i][j])); 
	  }      

      n = devide_kajuen();
      printf("%d\n",n);      
    }

  return(0);
}

Measured memory_bytes: 860
import java.util.*;
public class Main {
	static int ans;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for(int i = 0;i < n;i++) {
			boolean has = false;
			int d = sc.nextInt();
			for(int k:list) {
				if(d == k) {
					has = true;
					break;
				}
			}
			if(!has) {
				ans++;
				list.add(d);
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23252
import sys

def solve():
    readline = sys.stdin.readline
    H, W, M = map(int, readline().split())
    h = [0] * H
    w = [0] * W
    b = set()
    for _ in range(M):
        y, x = map(int, readline().split())
        x -= 1
        y -= 1
        h[y] += 1
        w[x] += 1
        b.add(y*W+x)
    h = sorted(zip(h, range(H)), reverse=True)
    ans = 0
    for i in range(W):
        x = w[i]
        for y, j in h:
            if x+y > ans:
                if j*W+i in b:
                    ans = x+y-1
                else:
                    ans = x+y
                    break
            else:
                break
    print(ans)

if __name__ == '__main__':
    solve()

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int l = a + b;
  int r = c + d;
  if (l > r){
    cout << "Left" << endl;
  }
  else if (l < r){
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}


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

#define CONST_CARD_NUM 52 //カード枚数

int main() {
	bool bHave[CONST_CARD_NUM + 1];
	//すべてのカードをfalseにする
	for (int i = 1; i <= CONST_CARD_NUM; i++)
	{
		bHave[i] = false;
	}

	int n;//枚数
	char cColor;//絵柄　S=スペード　H=ハート　C＝クラブ　D=ダイヤ
	int iCard;//カードの数字 1～13
	int iIndex;//カードの順番
	int iRemainder;//13割りの余り
	int iQuotient; //13割りの商
		
	//枚数の入力
	cin >> n;

	//所持カードの入力
	for (int i = 1; i <= n; i++)
	{
		cin >> cColor;
		cin >> iCard;

		switch (cColor)
		{
		case 'S':
			iIndex = iCard;
			break;
		case 'H':
			iIndex = iCard + 13;
			break;
		case 'C':
			iIndex = iCard + 26;
			break;
		case 'D':
			iIndex = iCard + 39;
			break;
		default:
			cout << "ふざけるなぁ,もう一回入力してください\n";
			i--;
			continue;
		}
		bHave[iIndex] = true;//カードを持っている
	}
	for (int i = 1; i <= CONST_CARD_NUM; i++)
	{
		//持ってないカードを出力
		if (bHave[i] == false)
		{
			iQuotient = i / 13;
			iRemainder = i % 13;
			if (iRemainder == 0)
			{
				iQuotient--;
				iRemainder = 13;
			}

			switch (iQuotient)
			{
			case 0:
				cout << "S " << iRemainder << endl;
				break;
			case 1:
				cout << "H " << iRemainder << endl;
				break;
			case 2:
				cout << "C " << iRemainder << endl;
				break;
			case 3:
				cout << "D " << iRemainder << endl;
				break;
			default:
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <limits>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>
 
using namespace std;
 
typedef long long int ll;
typedef std::numeric_limits<double> dbl;
const long long int LL_INF=1LL<<60;
 
vector<string> split(const string& input, char delimiter)
{
    stringstream stream(input);
    
    string field;
    vector<string> result;
    while (getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}
 
//#define DEBUG
 
ll A, B, C, D, E, M, N, K, Q, W, H, T, X, Y;
 
int main()
{
    cin >> A >> B >> C >> D;
    if (min(B, D) - max(A, C) < 0)
        cout << 0 << endl;
    else
        cout << (min(B, D) - max(A, C)) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

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

#define bil ((ll)1e9)
#define mod ((ll)1e9+7)

int main(int argc,char* argv[]){
    ll h,w,n;
    cin >> h >> w >> n;

    if(n==0){
        cout << (h-2)*(w-2) << endl;
        for(int i=1;i<10;i++)
            cout << "0" << endl;
        return 0;
    }

    vector<pll> ab(n);
    for(auto &x:ab){
        ll a,b;
        cin >> a >> b;
        x=make_pair(a,b);
    }

    vector<pll> sqare(0);
    for(auto x:ab){
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                sqare.push_back(make_pair(x.first-i,x.second-j));
            }
        }
    }

    sort(sqare.begin(),sqare.end());

    int count=1;
    vector<ll> ans(10);
    ans[0]=(h-2)*(w-2);
    for(ll i=0;i<sqare.size();i++){
        if(sqare[i].first<=0 || sqare[i].second<=0 || sqare[i].first+2>h || sqare[i].second+2>w)
            continue;
        if(i==sqare.size()-1){
          if(sqare[i]!=sqare[i-1]){
            ans[1]++;
            ans[0]--;
            break;
          }else{
            break;
          }
        }
        if(sqare[i]==sqare[i+1]){
            count++;
        }else{
            ans[count]++;
            count=1;
            ans[0]--;
        }
    }

    for(auto x:ans)
        cout << x << endl;

    return 0;
}


Measured memory_bytes: 20328
from collections import defaultdict
from string import ascii_uppercase
import sys, bisect, math
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

S = read_str()
N = len(S)

def solve():
    ans = 0
    if N == 1:
        return ans
    ans_01 = 0
    ans_10 = 0
    # 01
    for i in range(-(-N//2)):
        if i * 2 == N - 1:
            if S[2*i] == '1': ans_01 += 1
        else:
            if S[2*i:2*i + 2] == '00' or S[2*i:2*i + 2] == '11':
                ans_01 += 1
            elif S[2*i:2*i + 2] == '10':
                ans_01 += 2
    #10
    for i in range(-(-N//2)):
        if i * 2 == N - 1:
            if S[2*i] == '0': ans_10 += 1
        else:
            if S[2*i:2*i + 2] == '00' or S[2*i:2*i + 2] == '11':
                ans_10 += 1
            elif S[2*i:2*i + 2] == '01':
                ans_10 += 2
    ans = min(ans_01, ans_10)
    return ans


if __name__ == "__main__":
    print(solve())

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
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;}
int main(){
    string s; cin>>s;
    string ans = "Yes";
    if(s.length()%2) ans = "No";
    for(int i=0; i<s.length(); i+=2){
        if(s[i] != 'h' || s[i+1] != 'i') {
            ans = "No"; break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def rotate r, c, size, angle
    temp = []
    size.times{|c1| temp << @matrix[r-1+c1][c-1, size].dup}
    ((angle / 90) % 4).times{
        temp = temp.transpose
        temp.map!{|line| line.reverse}
    }
    size.times{|c1| @matrix[r-1+c1][c-1, size] = temp[c1]}
end

def reversal r, c, size
    size.times{|c1| size.times{|c2| @matrix[r-1+c1][c-1+c2] = 1-@matrix[r-1+c1][c-1+c2]}}
end

def leftshift r
    @matrix[r-1].rotate! 1
end

def rightshift r
    @matrix[r-1].rotate! -1
end

def islandreversal r, c
    x = @matrix[r-1][c-1]
    temp = [[r-1,c-1]]
    until temp.empty?
        temp2 = temp.pop
        if @matrix[temp2[0]][temp2[1]] == x
            @matrix[temp2[0]][temp2[1]] = 1 - @matrix[temp2[0]][temp2[1]]
            temp << [temp2[0]-1, temp2[1]] if temp2[0] > 0
            temp << [temp2[0]+1, temp2[1]] if temp2[0] < @n-1
            temp << [temp2[0], temp2[1]-1] if temp2[1] > 0
            temp << [temp2[0], temp2[1]+1] if temp2[1] < @n-1
        end
    end
end

@n, m = gets.chomp.split.map(&:to_i)
@matrix = []
@n.times{@matrix << gets.chomp.split.map(&:to_i)}
m.times{
    op, r, c, size, angle = gets.chomp.split.map(&:to_i)
    case op
    when 0 then rotate(r, c, size, angle)
    when 1 then reversal(r, c, size)
    when 2 then leftshift(r)
    when 3 then rightshift(r)
    when 4 then islandreversal(r, c)
    end
}
@matrix.each{|row| puts row.join(" ")}



Measured memory_bytes: 8920
#include <bits/stdc++.h>
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
 
using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

 
int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	ll x,y;
	cin >>x >>y;
	
	if(x<2 && y<2){puts("Brown");return 0; } 
	
	if(x<y) swap(x,y);
	if(x-y <=1 ) {puts("Brown");return 0; }
	puts("Alice");
	return 0;
}

Measured memory_bytes: 256