akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

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

	int maxi = 0, p;
	rep(i,n){
		int a, b;
		cin >> a >> b;
		if(maxi < a){
			maxi = a;
			p = b;
		}
	}
	cout << maxi + p << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n;
int a[N], b[N];
int c[N], d[N];
int p[3*N];
int pi[3*N];
int A[N];
bool test(int n, int k, int x){
    for (int i = 0; i < n; i++){
        A[i] = a[i]^x;
        printf("test %d %d\n",A[i],b[(i+k)%n]);
        //assert(A[i] == b[(i+k)%n]);
        if (A[i] != b[(i+k)%n]) return false;
    }
    return true;
}
int main(){
    int n;
    scanf("%d",&n);
    for (int i = 0; i < n; i++) scanf("%d",&a[i]);
    for (int i = 0; i < n; i++) scanf("%d",&b[i]);
    for (int i = 0; i < n; i++) c[i] = a[i]^a[(i+1)%n];
    for (int i = 0; i < n; i++) d[i] = b[i]^b[(i+1)%n];
    for (int i = 0; i < n; i++) p[i] = c[i];
    p[n] = -1;
    for (int i = 0; i < n; i++) p[i+n+1] = p[i+2*n+1] = d[i];
    for (int i = 1; i <= 3*n; i++){
        int j = pi[i-1];
        while (j > 0 && p[i] != p[j])
            j = pi[j-1];
        if (p[i] == p[j])
            j++;
        pi[i] = j;
    }
    for (int i = 3*n; i > 2*n; i--){
        if (pi[i] == n){
            int k = (n-i%n)%n;
            int x = b[0]^a[k];
            printf("%d %d\n",k,x);
        }
    }

}


Measured memory_bytes: 11264
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include <bits/stdc++.h>
#define ll long long
#define read(x) scanf("%d",&x)
using namespace std;
const int maxn = 2e5 + 10;

map<string,int > m;


int main()
{   
	m["Sunny"] = 0;
	m["Cloudy"] = 1;
	m["Rainy"] = 2;
	string s;
	cin>>s;
	int pos = (m[s]+1)%3;
	if(pos==0){
		cout<<"Sunny"<<endl;
	}else if(pos==1){
		cout<<"Cloudy"<<endl;
		
	}else{
		cout<<"Rainy"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define INF 1ll<<60
using namespace std;
signed main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  int a;
  string s;
  cin>>a>>s;
  if(a<3200)
  	cout<<"red"<<endl;
  else
  	cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<queue>
#include<algorithm>
#include<vector>
using namespace std;

priority_queue<int, vector<int>, less<int> > q; //新建一个从大到小的优先队列

int main(){
    ios::sync_with_stdio(false); //读入读出优化
    int n,m,tmp,ans=0;
    cin>>n>>m;
    for(int i=0;i<n;++i){
        cin>>tmp;
        q.push(tmp); //入队
    }
    for(int i=0;i<m;++i){
        ans+=q.top(); //加前m个元素
        q.pop();
    }
    cout<<ans<<endl; //输出
    return 0;
}

Measured memory_bytes: 256
package main

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

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func strSprit(str string) []string {
	cols := strings.Split(str, " ")
	return cols
}

func parseInt(str string) int {
	n, _ := strconv.Atoi(str)
	return n
}

func intSprit(str string) []int {
	strs := strSprit(str)
	cols := make([]int, len(strs))
	for i, v := range strs {
		cols[i] = parseInt(v)
	}
	return cols
}

func bitCount(n uint) int {

	x := uint64(n)

	const m = 1<<64 - 1
	const m0 = 0x5555555555555555
	const m1 = 0x3333333333333333
	const m2 = 0x0f0f0f0f0f0f0f0f

	x = x>>1&(m0&m) + x&(m0&m)
	x = x>>2&(m1&m) + x&(m1&m)
	x = (x>>4 + x) & (m2 & m)
	x += x >> 8
	x += x >> 16
	x += x >> 32

	return int(x) & (1<<7 - 1)
}

func bitExist(n, i int) bool {
	return ((n >> uint(i)) & 1) == 1
}

func setBit(d, n int) int {
	t := 1 << uint(n)
	return d | t
}

func intAbs(n int) int {
	return int(math.Abs(float64(n)))
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////

func main() {
	line := readBigLine()
	N := parseInt(line)

	b := intSprit(readBigLine())

	res := []int{}

	for len(b) > 0 {
		t := -1
		idx := -1
		for i := 0; i < len(b); i++ {
			if i+1 == b[i] {
				t = b[i]
				idx = i
			}
		}
		if t == -1 {
			fmt.Println(t)
			return
		}
		b = append(b[:idx], b[idx+1:]...)
		res = append(res, t)
	}

	for i := N - 1; i >= 0; i-- {
		fmt.Println(res[i])
	}
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#define ll long long
char a[101000];
int main()
{
    ll i,j,k,m,n,x,b;
    cin>>a;
    n=strlen(a);
    int cnt=0;
    for(i=1;i<n-1;i++)
    {
        if(a[i-1]!=a[i+1])
        {
            cnt++;
            a[i]=a[i-1];
        }
        else
        {
            i++;
        }
    }
    if(cnt%2!=0)
        cout<<"First"<<endl;
    else
        cout<<"Second"<<endl;
    return 0;
}


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

using namespace std;

int main() {
  int a; // 
  int b; // 
  cin >> a >> b;
  if ((a+b) % 2 == 0){
    cout << (a+b)/2 << endl;
  } else
    {
      cout << (a+b)/2 + 1 << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;
int mod = 1e9+7;

int a[3];
signed main(){
	int d, flag = 0;
	rep(i,3)scanf("%lld", &a[i]);
	scanf("%lld", &d);
	if(llabs(a[0]-a[2]) <= d)flag = 1;
	if(llabs(a[0]-a[1]) <= d and llabs(a[1]-a[2]) <= d)flag = 1;
	if(flag)printf("Yes\n");
	else printf("No\n");
	return 0;
}




Measured memory_bytes: 384
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
constexpr double BIGP = 1000000007L;
constexpr double INF_I = std::numeric_limits<ll>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll A, B;
    cin >> A >> B;
    if (13 <= A)
    {
        cout << B;
    }
    else if (6 <= A)
    {
        cout << B/2;
    }
    else
    {
        cout << 0;
    }

    return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  int a[n],b[m],ans[2000] = {0};
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  for(int i = 0; i < m; i++){
    cin >> b[i];
  }

  for(int i = 0; i < m; i++){
    for(int j = 0; j < n; j++){
      if(b[i] >= a[j]){
	ans[j]++;
	break;
      }
    }
  }
  int res = 0;
  int num = 0;
  for(int i = 0; i < n; i++){
    res = max(res, ans[i]);
    if(res == ans[i])num = i + 1;
  }
  cout << num << endl;
  return 0;
}

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

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

    long long ans = 1e9;
    for(int i = 1; i <= 100; i++) {
        long long x = 0;
        for(int j = 0; j < n; j++) {
            x += pow(abs(i - a[j]), 2);
        }
        ans = min(ans, x);
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define str string
#define sonic ios_base::sync_with_stdio(0)
using namespace std;
int main(){
	sonic;
	ll n;
	cin>>n;
	for(ll i=1;i<=n;i++){
		for(ll j=1;j<=n;j++){
			if(i*j==n){
				if(i<10 && j<10){
					cout<<"Yes";
					return 0;
				}
			}
		}
	}
	cout<<"No";
}

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

int main() {
	int n,i,j,k;
	cin >>n;
	int a[3][n+1],dp[3][n+1];
	for(i=1;i<=n;i++)
    {
        cin >>a[0][i]>>a[1][i]>>a[2][i];
    }
    dp[0][1]=a[0][1];
    dp[1][1]=a[1][1];
    dp[2][1]=a[2][1];
    
    for(i=2;i<=n;i++)
    {
        dp[0][i]=a[0][i]+max(dp[1][i-1],dp[2][i-1]);
        dp[1][i]=a[1][i]+max(dp[0][i-1],dp[2][i-1]);
        dp[2][i]=a[2][i]+max(dp[1][i-1],dp[0][i-1]);
    }
   
    cout<<max(dp[0][n],max(dp[1][n],dp[2][n]));
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
const ll INF = 1e16;

void solver(int N, int K, double &ans){

    vector<int> x(N, 1);
    for(int n = 0; n != N; ++n){
        int tmp = n + 1;

        while(tmp*x.at(n) < K){
            x.at(n) *= 2;
        }
    }

    for(int i = 0; i != N; ++i){
        double tmp = 1.0/x.at(i);
        ans += tmp;
    }
    ans /= N;
}

int main(){

    int N, K;
    cin >> N >> K;

    double ans{};
    solver(N, K, ans);

    cout << fixed << setprecision(10);
    cout << ans << endl;
    
    return 0;
}

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

const long long maxn = 2e5+10 ;
vector<long long> adj[maxn] ;
bool mark[maxn] ;

long long a, b, c ;
bool flag;

long long dfs(long long u, long long d = 0){

    mark[u] = 1 ;
    if(d%2 == 0)
        a++ ;
    else
        b++ ;
    if(d>0)
        flag = 1;
    for(auto v:adj[u]){
        c++ ;
        if(!mark[v]){

            dfs(v, d+1) ;

        }

    }

}

int main() {

    ios::sync_with_stdio(false) ;
    cin.tie(0) ;

    long long n ;
    cin >> n ;
    for(long long i = 0; i < n; i++){

        long long u, v ;
        cin >> u >> v ;
        u-- ;
        v-- ;
        v += 1e5 ;
        adj[u].push_back(v) ;
        adj[v].push_back(u) ;

    }
    long long ans = 0 ;
    for(long long i = 0; i < 1e5; i++){

        a = 0 ;
        b = 0 ;
        c = 0 ;
        flag=0;
        if(!mark[i])
            dfs(i) ;
        if(flag){
            ans += a*b-c/2 ;
//            cout << a << ' ' << b << ' ' << c << endl ;
        }


    }
    cout << ans ;

}


Measured memory_bytes: 10240
i=[1,2,3,4,5,6,7,8,9]
j=[1,2,3,4,5,6,7,8,9]
for i1 in i:
    for j1 in j:
        answer=i1*j1
        print(str(i1)+"x"+str(j1)+"="+str(answer))


Measured memory_bytes: 5540
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int N;

void solve(){
    cin >> N;
    rep(i,3501){
        rep(j,3501){
            if(4*i*j<=N*(i+j)) continue;
            if ((ll)N*(ll)i*(ll)j%((ll)4*(ll)i*(ll)j-(ll)N*((ll)i+(ll)j))) continue;
            ll k=((ll)N*(ll)i*(ll)j)/((ll)4*(ll)i*(ll)j-(ll)N*((ll)i+(ll)j));
            cout << i << " " << j << " " << k;
            return;
        }
    }
}

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

Measured memory_bytes: 256
// v[i] >= c[i] となるものをすべて取れば利益X-Yを最大化できる.
#include<iostream>
using namespace std;
int main() {
  int n, v[25], c[25], ans=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> v[i];
  }
  for(int i=0;i<n;i++){
    cin >> c[i];
  }
  for(int i=0;i<n;i++){
    if(v[i] >= c[i]) ans += v[i] - c[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def CountingSort(A,B,k):
  C = [0]*(k+1)
  for j in range(n):
    C[A[j]] += 1
  for i in range(1,k+1):
    C[i] += C[i-1]
  for j in range(n-1,-1,-1):
    B[C[A[j]]-1] = A[j]
    C[A[j]] -= 1
n = int(input())
A = [int(i) for i in input().split()]
B = [[] for i in range(n)]
CountingSort(A,B,max(A))
print(" ".join(map(str,B)))


Measured memory_bytes: 242552
#ifndef INCLUDED_ROLLING_HASH_HPP
#define INCLUDED_ROLLING_HASH_HPP

#include <vector>
#include <string>

class rolling_hash {
public:
	using u64 = std::uint_fast64_t;
	using size_type = std::uint_fast32_t;
	using i128 = __int128_t;

	static constexpr u64 MOD = (1uL << 61) - 1;
	static constexpr u64 base = 20200213;

	std::string str;
	std::vector<u64> hash_, pow;

private:
	static constexpr u64 mask30 = (1ul << 30) - 1;
	static constexpr u64 mask31 = (1ul << 31) - 1;

	u64 mul(i128 a, i128 b) const {
		i128 t = a * b;
		t = (t >> 61) + (t & MOD);
		
		if(t >= MOD) return t - MOD;
		return t;
	}
	size_type xorshift(size_type x) const {
		x ^= x << 13;
		x ^= x >> 17;
		x ^= x << 5;
		return x;
	}

public:
	rolling_hash(const rolling_hash &) = default;
	rolling_hash(rolling_hash&&) = default;

	rolling_hash() : str() {};
	rolling_hash(const std::string & str) : str(str) {
		hash_.resize(str.size() + 1, 0);
		pow.resize(str.size() + 1, 1);
		for(size_type i = 0; i < str.size(); i++) {
			hash_[i + 1] = mul(hash_[i], base) + xorshift(str[i] + 1);
			pow[i + 1] = mul(pow[i], base);
			if(hash_[i + 1] >= MOD) hash_[i + 1] -= MOD;
		}
	}

	u64 hash() const { return hash_.back(); }
	u64 hash(size_type l, size_type r) const {
		u64 ret = MOD + hash_[r] - mul(hash_[l], pow[r - l]);
		return ret < MOD ? ret : ret - MOD;
	}
	
	size_type size() const { return str.size(); }
};

#endif

#include <iostream>

int main() {
	int n; scanf("%d", &n);
	std::string s; std::cin >> s;
	
	int ans = 0;
	rolling_hash hash(s);
	for(int i = 0; i < s.size(); i++) {
		for(int j = i; j < s.size(); j++) {
			while(i + ans < j and j + ans < n) {
				if(hash.hash(i, i + ans + 1) != hash.hash(j, j + ans + 1)) break;
				ans++;
			}
		}
	}

	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
#include <stdio.h>

using namespace std;

int a, b;
char c;
int main(){
	while (true){
		cin >> a >> c >> b;
		if (c == '?')break;
		int ans = 0;
		switch (c)
		{
		case '+':
			ans = a + b;
			break;
		case '-':
			ans = a - b;
			break;
		case '*':
			ans = a*b;
			break;
		case '/':
			ans = a / b;
			break;
		default:
			exit(1);
		}
		cout << ans << endl;
	}
	

	return 0;
}

Measured memory_bytes: 1160
n,m=map(int,input().split())
l=[int(i) for i in input().split()]
l=l[1:]
for i in range(n-1):
  s=[int(j) for j in input().split()]
  s=s[1:]
  ln=[]
  for le in l:
    if le in s:
      ln.append(le)
  l=ln
print(len(l))


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <stack>
#include <utility>
#include <algorithm>

using namespace std;
typedef pair<int,int> mp;

int main(){
    while(true){
        int m,t,p,r;
        cin >> m >> t >> p >> r;
        if(m==0)break;
        vector<vector<int> > score(t,vector<int>(p,-1));
        for(int i=0;i<r;i++){
            int m1,t1,p1,j;
            cin >> m1 >> t1 >> p1 >> j;
            t1--;
            p1--;
            if(j!=0){
                score[t1][p1]-=20;
            }
            else{
                if(score[t1][p1]<-1){
                    score[t1][p1]=m1-score[t1][p1]-1;
                }
                else{
                    score[t1][p1]=m1;
                }
            }
        }
        vector<pair<mp,int> > pr(t);
        pair<mp,int> temp;
        for(int i=0;i<t;i++){
            temp.first.first=0;
            temp.first.second=0;
            temp.second=-(i+1);
            pr[i]=temp;
            for(int j=0;j<p;j++){
                if(score[i][j]>=0){
                    temp.first.first--;
                    temp.first.second+=score[i][j];
                    pr[i]=temp;
                }
            }
        }
        sort(pr.begin(),pr.end());
        for(int i=0;i<t;i++){
            cout << -pr[i].second;
            if(i<t-1 && pr[i].first==pr[i+1].first)cout << '=';
            else if(i!=t-1)cout << ',';
        }
        cout << endl;

    }
    return 0;
}

Measured memory_bytes: 3004
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;

typedef long long ll;
// const int INF = 1e8;
const ll INF = 1LL << 60;
typedef pair<int, int> P;

int N, P2;
string S;

int main() {
    cin >> N >> P2 >> S;

    if (10 % P2 == 0) {
        ll ans = 0;
        rep(i, N) {
            if ((S[i] - '0') % P2 == 0) {
                ans += i + 1;
            }
        }
        cout << ans << endl;
        return 0;
    }

    vector<ll> d(N + 1);
    ll ten = 1;
    for (ll i = N - 1; i >= 0; i--) {
        ll a = (S[i] - '0') * ten % P2;

        d[i] = (d[i + 1] + a) % P2;
        ten *= 10; ten %= P2;
    }
    vector<ll> cnt(P2);
    ll ans = 0;
    for (ll i = N; i >= 0; i--) {
        ans += cnt[d[i]];
        cnt[d[i]]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2180
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int h, w, m;
map<int, vector<int> > ma, ma2;
vector<int> tmp;
set<II> s;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> h >> w >> m;
    FOR(i,1,m) {
        int x, y;
        cin >> x >> y;
        ma[x].push_back(y);
        ma2[y].push_back(x);
    }
    FORALL(it, ma2) {
        int y = it->FI;
        s.insert(II(SZ(it->SE), y));
    }
    int res = 0;
    FORALL(it, ma) {
        tmp = it->SE;
        int g = SZ(tmp);
        FOR(i,0,SZ(tmp)-1) {
            int y = tmp[i];
            res = max(res, g + SZ(ma2[y]) - 1);
            s.erase(II(SZ(ma2[y]), y));
        }

        if (SZ(s)) {
            auto it2 = s.rbegin();
            res = max(res, g + it2->FI);
        }
        else res = max(res, g);

        FOR(i,0,SZ(tmp)-1) {
            int y = tmp[i];
            s.insert(II(SZ(ma2[y]), y));
        }
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 83264
//递归求第n个斐波那契数列
#include<iostream>
using namespace std;

int F[50];
//记忆化递归生成斐波那契数列 
/*int fibonacci(int n)
{
	if(n==1||n==2)
		return F[n]=1;
	if(F[n])
		return F[n];
	else return F[n]=fibonacci(n-1)+fibonacci(n-2);
}*/
//动态规划法生成斐波那契数列
/*
int fibonacci(int n)
{
	if(n==0||n==1)
		F[n]=1;
	for(int i=2;i<n;i++)
	{
		F[i]=F[i-1]+F[i-2];		
	}	
} */
int main()
{
	int n;
	cin>>n;
	F[0]=F[1]=1;
	for(int i=2;i<=n;i++)
	{
		F[i]=F[i-1]+F[i-2];		
	}
	//int result=fibonacci(n);
	cout<<F[n]<<endl;
	return 0;
}


Measured memory_bytes: 3104
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int small = sc.nextInt();
        int medium = sc.nextInt();
        int large = sc.nextInt();
        String ans = "";
        if(small < medium && medium < large) {
            ans = "Yes";
        } else {
            ans = "No";
        }
        System.out.println(ans);
        sc.close();
    }
}


Measured memory_bytes: 26152
function Main(input) {
  var five = (input.match(/5/g) || []).length;
  var seven = (input.match(/7/g) || []).length;

  ( five == 2 && seven == 1)  ? console.log("YES") : console.log("NO");
}

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

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

int main() {
  int a, b, c;
  cin >> a >> b;
  
  c = a * b;
  
  if( c % 2 == 0){
    cout << "Even" << endl;
  }
  
  else{
    cout << "Odd" << endl;
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
 
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; }
 
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

const int INF = 1e9;
const ll MOD = 1e9+7;

ll dfs(vector<vi> &G, int k, int v, int p){
  int can_use_color;
  if(p==-1) can_use_color=k-1;
  else can_use_color=k-2;
  
  ll res=1;
  for(auto u: G[v]){
    if(u==p) continue;
    res*=(ll)can_use_color;
    res%=MOD;
    can_use_color--;
  }
  for(auto u: G[v]){
    if(u==p) continue;
    res*=dfs(G,k,u,v);
    res%=MOD;
  }
  return res;
}

signed main()
{
  int n,k;
  cin>>n>>k;
  vector<vi> G(n);
  rep(i,n-1){
    int a,b;cin>>a>>b; a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  ll ans=k*dfs(G,k,0,-1);
  ans%=MOD;
  cout<<ans<<endl;
}



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

int main() {
	ll n;
	cin >> n;
	ll y_max = sqrt(n)+1;
	//printf("y_max=%lld\n",y_max);
	vector<int> m(y_max+1,0); // べき乗の個数
	int cnt[100]; // 加算数
	ll tmp = n;
	ll y=2;
	while (tmp!=1) {
		if (tmp%y==0) {
			tmp/=y;
			m[y]++;
		}
		else {
			y++;
		} 
		//printf("%lld,%lld\n",y,y_max);
		if (y>y_max && n==tmp) {
			//printf("exceed");
			cout << 1 << endl;
			return 0;
		}
		if (y>y_max) break;
	}
	//printf("%lld\n",tmp);
	rep(i,50) {
		for (int j=i*(i+1)/2;j<(i+1)*(i+2)/2;j++) {
			if (j<100) cnt[j] = i;
		}
	}
	ll ans = 0;
	if (tmp!=1) ans++;
	rep(i,y_max+1) ans += cnt[m[i]];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 7220
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

ll MOD = 1e9 + 7;
const ll max_n = 200003;
vector<ll> fact(max_n);
bool fact_init = false;

ll pow(ll a, ll b){
	if(a == 0) return 0;
	if(b == 0) return 1;
	if(b % 2 == 1) return a * pow(a, b - 1) % MOD;

	ll d = pow(a, b / 2) % MOD;
	return d * d % MOD;
}

ll comb(ll n, ll k){
	if(!fact_init){
		fact[0] = 1;
		fact[1] = 1;

		for(ll i = 2; i < max_n; i++){
			fact[i] = fact[i-1] * i;
			fact[i] %= MOD;
		}

		fact_init = true;
	}

	ll ret = fact[n];
	ret *= pow(fact[k],MOD-2);
	ret %= MOD;
	ret *= pow(fact[n-k],MOD-2);
	ret %= MOD;

	return ret;

	// X^(-1) = X^(p-2) (mod p) (Fermat's little theorem)
}


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

	ll N, M, K;
	cin >> N >> M >> K;

	ll cnt = comb(N * M - 2, K - 2);

	ll ans = 0;
	for(ll d = 1; d < M; d++){
		ll t = cnt * N * N;
		t %= MOD;
		t *= d * (M - d);
		t %= MOD;

		ans += t;
		ans %= MOD;
	}

	for(ll d = 1; d < N; d++){
		ll t = cnt * M * M;
		t %= MOD;
		t *= d * (N - d);
		t %= MOD;

		ans += t;
		ans %= MOD;
	}

	cout << ans << endl;
}


Measured memory_bytes: 1792
from itertools import permutations
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
M = []
for i in range(N):
    M.append(i+1) 
p, q = 0, 0
for i, n in enumerate(list(permutations(M))):
    if n == P:
        p = i
    if n == Q:
        q = i
print(abs(p - q))

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

int main() {
    ll x,n,d,y;
    cin>>n>>d;
    ll cnt=0;
    while(n--){
        cin>>x>>y;
        if(x*x+y*y<=d*d) cnt++;
    }
    cout<<cnt;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] H = new int[N];
        for (int i = 0; i < N; i++) {
            H[i] = sc.nextInt();
        }

        int ans = 0;
        for (int i = 1; i < N; i++) {
            int max = 0;
            for (int j = 0; j <= i; j++) {
                if (H[j] > max) {
                    max = H[j];
                }
            }
            if (max == H[i]) {
                ans++;
            }
        }
        System.out.println(ans+1);
    }
}


Measured memory_bytes: 23124
import java.io.*;
import java.util.*;

class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        System.out.printf("%d %d %.5f\n", (a/b), (a%b), ((double)a/b));
    }
}

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

using namespace std;

using ll = long long;

const ll mod = 1e9 + 7;

ll sum(ll a, ll b) { return (a + b) % mod; }
void add(ll& a, ll b) { a = sum(a, b); }
ll sub(ll a, ll b) { return (a - b + mod) % mod; }
ll mul(ll a, ll b) { return a * b % mod; }

int main() {
    ios_base::sync_with_stdio(false);
    ll n, k; cin >> n >> k;
    vector<ll> a(n);
    for (ll& x : a) cin >> x;
    ll ans(0);
    for (int i(0); i < n; ++i) {
        ll cnt(0);
        for (int j(i + 1); j < n; ++j)
            cnt += a[j] < a[i];
        add(ans, mul(cnt, k));
        for (int j(0); j < i; ++j)
            cnt += a[j] < a[i];
        add(ans, mul(cnt, k * (k - 1) / 2 % mod));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
A=[list(map(int,input().split())) for _ in range(N)]

ans=0
for i in range(N):
    tmp=0
    for a,b in zip(A[i],B):
        tmp+=a*b
    tmp+=C
    if tmp>0: ans+=1
print(ans)

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

int main(){
  string s,t;
  cin >> s;
  t = "CODEFESTIVAL2016";
  int ans = 0;
  rep(i,16){
    if(s[i] != t[i]){
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}


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

const int N = 2010;

int a[N][N];
int n, m, test;
int pre[N][N], preleft[N][N], preup[N][N];

int query(int (*pre)[N], int x1, int y1, int x2, int y2){
	if (x1 > x2 || y1 > y2) return 0;
	return pre[x2][y2] - pre[x1 - 1][y2] - pre[x2][y1 - 1] + pre[x1 - 1][y1 - 1];
}

int main(){
	scanf("%d%d%d", &n, &m, &test);
	for (int i = 1; i <= n; ++ i){
		for (int j = 1; j <= m; ++ j){
			scanf("%1d", &a[i][j]);
			pre[i][j] = a[i][j];
		}
	}
	for (int i = 1; i <= n; ++ i){
		for (int j = 1; j <= m; ++ j){
			if (a[i][j]){
				if (a[i - 1][j]){
					preup[i][j] = 1;
				}
				if (a[i][j - 1]){
					preleft[i][j] = 1;
				}
			}
		}
	}
	for (int i = 1; i <= n; ++ i){
		for (int j = 0; j <= m; ++ j){
			pre[i][j] += pre[i - 1][j];
			preup[i][j] += preup[i - 1][j];
			preleft[i][j] += preleft[i - 1][j];
		}
	}
	for (int i = 0; i <= n; ++ i){
		for (int j = 1; j <= m; ++ j){
			pre[i][j] += pre[i][j - 1];
			preup[i][j] += preup[i][j - 1];
			preleft[i][j] += preleft[i][j - 1];
		}
	}
	while (test --){
		int x1, y1, x2, y2;
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		printf("%d\n", query(pre, x1, y1, x2, y2) - query(preup, x1 + 1, y1, x2, y2) - query(preleft, x1, y1 + 1, x2, y2));
	}
	return 0;
}

Measured memory_bytes: 64896
#include <stdio.h>
#pragma warning(disable:4996)
int main(void) {
	int n, i, p, q;
	int j,k,l,m;
	int number[1000];
	int count[1000];
	int ans[1000];
	int c=0;
	int d;
	
	scanf("%d", &n);
	while (n != 0) {
		d = c;
		int a = 0, b = 0;
		for (j = 0; j < n; j++) {
			scanf("%d%d%d", &i, &p, &q);
			number[a] = i;
			count[b] = p*q;
			a++;
			b++;
			
			}
		for (l = 0; l < a - 1; l++) {
			for (m = l + 1; m < a; m++) {
				if (number[l] == number[m]) {
					count[l] = count[l] + count[m];
				}
			}
		}
		for (j = 0; j < n; j++) {
			if (count[j] >= 1000000) {
				ans[c] = number[j];
				c++;
			}

		}
		if (d == c) {
			ans[c] = 0;
			c++;
		}
		scanf("%d", &n);

	}

	for (k = 0; k < c; k++) {
		if (ans[k] == 0) {
			printf("NA\n");
		}
		else {
			printf("%d\n", ans[k]);
		}
	}

	return 0;
}

Measured memory_bytes: 1740
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] t = new int[n];
			for(int i = 0 ; i < n ; i++) {
				t[i] = sc.nextInt();
			}
			int m = sc.nextInt();
			int[] p = new int[m];
			int[] x = new int[m];
			for(int i = 0 ; i < m ; i++) {
				p[i] = sc.nextInt();
				x[i] = sc.nextInt();
			}
			int sum = Arrays.stream(t).sum();
			for(int i = 0 ; i < m ; i++) {
				System.out.println(sum - (t[p[i] - 1] - x[i]));
			}
		}

	}

}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll a, b, x;
    cin >> a >> b >> x;

    if(a == 0 && b == 0) PR(1);
    else if(a == 0 && b > 0) PR(b/x+1);
    else PR(b/x-(a-1)/x);

    return 0;
}

/*



*/

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=2e5+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
   }

int n,k;


void solve() {
      cin>>n>>k;
      vi a(n,0);
      rep(i,0,n) cin>>a[i];
      sort(all(a));
	  int ans=1,l=0,r=n-1,sign=1;
	  
	  if(k%2) {
		  ans=a[n-1];
	      k--;
	      r--;	 
	    if(ans<0) sign=-1;
      }  
      //~ cout<<ans<<endl;
	  while(k) {
		    int x=a[l]*a[l+1];
		    int y=a[r]*a[r-1];
		    if(x*sign>y*sign) {
				  l+=2;
				  ans=((ans%mod)*(x%mod))%mod;
				}
			else {
				  r-=2;
				  ans=((ans%mod)*(y%mod))%mod;
				}
				k-=2;	
		  }
		  //~ cout<<ans<<endl;
		  if(ans<0)
		    ans=(ans+mod)%mod;
		  
		  cout<<ans<<endl;  	
          
 }

    
int32_t main() {
	cool;
	int t=1;

	//cin>>t;
	while(t--)
	solve();


return 0;	   
}


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

int main()
{
    string str;
    cin >> str;
    vector<int> indices;
    for (int i = 0; i < str.size(); ++i)
    {
        if (str[i] == 'W')
        {
            indices.push_back(i);
        }
    }
    long long ans = 0;
    int cnt = 0;
    for (int index : indices)
    {
        ans += index - cnt;
        ++cnt;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1532
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long &x, long long &y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a%b, y, x);
	y -= a / b * x;
	return d;
}

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

int main() {
	int n, k;
	cin >> n >> k;
	vint a(n);
	rep(i, n) {
		cin >> a[i];
	}
	int cnt = 0;
	int ans = 0;
	cnt += k;
	ans++;
	while (cnt < n) {
		cnt += k - 1;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define _printV(vec) for(int i = 0; i < SZ(vec); i++){cout << vec[i];if (i==SZ(vec)-1){cout<<endl;}else{cout << " ";}}
#define printV(vec) cout<<#vec<<":";_printV(vec)
#define _printA(arr,n) for(int i = 0; i < n; i++){cout << arr[i];if (i==n-1){cout<<endl;}else{cout << " ";}}
#define printA(arr) cout<<#arr<<":";_printA(arr,sizeof(arr)/sizeof(arr[0]))
#define LLINF (1LL<<62)
#define puts(var) cout<<#var<<":"<<var<<" "
typedef long long ll;

int main()
{
 int N;
  cin >> N;
  int A[N];
  double sum = 0.0;
  REP(i,N){
    cin >> A[i];
    sum += A[i];
  }
  sum /= N;

  double mindiff = LLINF;
  int minArg = 0;

  REP(i,N){
    double tmp = fabs(A[i]-sum);
    if (mindiff > tmp){
      minArg = i;
      mindiff = tmp;
    }
  }

  cout << minArg << endl;

  return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, Y = map(int, readline().split())

    Y //= 1000

    x, y, z = -1, -1, -1
    for i in range(N + 1):
        for j in range(N + 1):
            k = N - i - j
            if k >= 0 and 10 * i + 5 * j + k == Y:
                x, y, z = i, j, k
                break

    print(x, y, z)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 72724
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
const int MOD=1e9+7;
ll r2=(MOD+1)/2;
int n,a[SZ],m,p[SZ],q[SZ],f[3333][3333];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;++i)
		cin>>a[i];
	for(int i=1;i<=m;++i)
		cin>>p[i]>>q[i];
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j)
			if(i!=j) f[i][j]=(a[i]>a[j]);
	ll ans=0;
	for(int i=1;i<=m;++i)
	{
		int u=(f[p[i]][q[i]]+f[q[i]][p[i]])%MOD*r2%MOD;
		f[p[i]][q[i]]=f[q[i]][p[i]]=u;
		for(int t=1;t<=n;++t)
		{
			if(t!=p[i]&&t!=q[i]);else continue;
			int u=(f[t][p[i]]+f[t][q[i]])%MOD*r2%MOD;
			f[t][p[i]]=f[t][q[i]]=u;
			u=(f[p[i]][t]+f[q[i]][t])%MOD*r2%MOD;
			f[p[i]][t]=f[q[i]][t]=u;
		}
	}
	for(int i=1;i<=n;++i)
		for(int j=i+1;j<=n;++j)
			(ans+=f[i][j])%=MOD;
	for(int j=1;j<=m;++j)
		ans=ans*2LL%MOD;
	ans=(ans%MOD+MOD)%MOD;
	cout<<ans<<"\n";
}


Measured memory_bytes: 47360
import sys
from fractions import gcd
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,M=map(int,input().split())
    a=tuple(map(lambda x:int(x)//2,input().split()))
    t=a[0]
    c=0
    while True:
        if t%2==0:
            c+=1
            t//=2
        else:
            break
    l=a[0]
    for x in a[1:]:
        if x%(2**c)!=0 or x%(2**(c+1))==0:
            print(0)
            exit()
        l=l*x//gcd(l,x)
    print((M+l)//(l*2))

        

if __name__ == '__main__':
    main()


Measured memory_bytes: 89836
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			String input = sc.nextLine();
			System.out.println(countSubstring(input, "JOI"));
			System.out.println(countSubstring(input, "IOI"));
		}
		
	}

	
	/**
	 * テ」ツ?づ」ツつ鬼tringテ」ツ?ョテ、ツクツュテ」ツ?ォテ・ツ青ォテ」ツ?セテ」ツつ古」ツつ凝・ツ按・テ」ツ?ョStringテ」ツ?ョテ・ツ?凝ヲツ閉ーテ」ツつ津ヲツ閉ーテ」ツ?暗」ツ?セテ」ツ??
	 * @param str テヲツ篠「テァツエツ「テ・ツッツセティツアツ。テ」ツ?ョテヲツ鳴?
	 * @param q テヲツ閉ーテ」ツ?暗」ツ?淌」ツ??ィツヲツ?ァツエツ?
	 * @return
	 */
	static int countSubstring(String str, String q) {
		int result = 0;
		String ss = null;
		for(int i = 0; i < str.length() - 2; i++) {
			ss = str.substring(i, i+3);
			if(ss.equals(q)) result++;
		}
		return result;
	}
	
	
	
}

Measured memory_bytes: 25012
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int h,w;
    cin >> h >> w;
    int count = 0;
    for(int i = 0;i < h;i++)
    {
        for(int j = 0;j < w;j++)
        {
            char ch;
            cin >> ch;
            if(ch == '#')
            {
                count++;
            }
        }
    }
    if(count == (h + w - 1))
    {
        cout << "Possible\n";
    }
    else
    {
        cout << "Impossible\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
# ABC129D - Lamp
def main():
    H, W, *S = open(0).read().split()
    H, W = int(H), int(W)
    L, R = [[0] * W for _ in range(H)], [[0] * W for _ in range(H)]
    U, D = [[0] * W for _ in range(H)], [[0] * W for _ in range(H)]
    for x1 in range(H):
        for y1 in range(W):
            if S[x1][y1] == ".":  # left and upper sides of S
                U[x1][y1] = U[x1 - 1][y1] + 1
                L[x1][y1] = L[x1][y1 - 1] + 1
            x2, y2 = -x1 - 1, -y1 - 1
            if S[x2][y2] == ".":  # right and under sides
                D[x2][y2] = D[x2 + 1][y2] + 1
                R[x2][y2] = R[x2][y2 + 1] + 1
    ans = max(
        L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3 for i in range(H) for j in range(W)
    )
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 176600
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define INF (1 << 21)

int main(){
  int n,m;
  int a,b,ab;
  int cost[101][101];
  int min_cost[101];
  bool used[101];
  while(1){
    cin >> n;
    if(n == 0) break;
    cin >> m;
    for(int i=0;i<101;i++){
      for(int j=0;j<101;j++){
	cost[i][j] = INF;
      }
    }
    for(int i=0;i<m;i++){
      scanf("%d,%d,%d",&a,&b,&ab);
      cost[a][b] = ab / 100 - 1;
      cost[b][a] = ab / 100 - 1;
    }
    for(int i=0;i<n;i++){
      min_cost[i] = INF;
      used[i] = false;
    }
    min_cost[0] = 0;
    int ans = 0;
    while(1){
      int v = -1;
      for(int i=0;i<n;i++){
	if(!used[i] && (v == -1 || min_cost[i] < min_cost[v])){
	  v = i;
	}
      }
      if(v == -1) break;
      used[v] = true;
      ans += min_cost[v];
      for(int i=0;i<n;i++){
	min_cost[i] = min(min_cost[i],cost[v][i]);
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1284
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
using ll = long long;
int main()
{
    int n;
    cin >> n;
    ll T,A;
    cin >> T >> A;
    for(int i = 1;i < n;i++)
    {
        ll t,a;
        cin >> t >> a;
        if(t < T || a < A)
        {
            ll k = max(ceil((long double)T / t),ceil((long double)A / a));
            t *= k;
            a *= k;
        }
        T = t;
        A = a;
    }
    cout << A + T << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    vector<int> xd(n+1);
    vector<int> yd(m+1);
    for(int i = 0; i < n; i++)
    {
        cin >> xd[i];
    }
    for(int j = 0; j < m; j++)
    {
        cin >> yd[j];
    }
    xd[n] = x;
    yd[m] = y;
    sort(xd.begin(), xd.end());
    sort(yd.begin(), yd.end());
    if(xd[n] < yd[0])
    {
        cout << "No War" << endl;
    }
    else
    {
        cout << "War" << endl;
    }
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n, d =map(int,input().split())
    ans = 0
    for i in range(n):
        x, y = map(int,input().split())
        if x**2 + y**2 <= d**2:
            ans += 1
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 9104
#include<iostream>
#include <cstring>
using namespace std;
int main() {
    int a = 0, b = 0;
    char S[200001] , T[200001];
    cin >> S; cin >> T;
    for (int i = 0; i <= strlen(S); i++){
        if (S[i] == T[i]) b++;
        else a++; }
    if (0 == a && 0==b ) cout << b;
    else  cout << a;
    return 0;

}

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

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    for (int a = 1; a < n; a++) {
        ans += (n - 1) / a;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3564
#include<stdio.h>
int main(void)
{
	int S,h,m,s;
	scanf("%d",&S);
	if(S>=86400||S<0){
		return 0;
	}
	
	h=S/3600;
	m=S%3600/60;
	s=S%3600%60;
	printf("%d:%d:%d\n",h,m,s);
	
  	return 0;
}

Measured memory_bytes: 592
def calc(arr, flag)
  (1...arr.size).each{|i| arr[i] += arr[i-1] }
  if flag
    arr.each{ |v| $list[v] ||= 0; $list[v] += 1 }
  else arr.each{ |v| $list[v].nil? ? next : $res += $list[v] }
  end
end
loop do
  $n, $m = gets.split.map(&:to_i)
  break if $n == 0
  $list = {}
  $res = 0
  l = $n.times.map{ gets.to_i }
  k = $m.times.map{ gets.to_i }
  (0...$n).each{|i| calc(l[i..-1], true) }
  (0...$m).each{|i| calc(k[i..-1], false) }
  p $res
end

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

int main(){
    int ans=0,cnt=0;
  string S;
    cin >> S;
    for(int i=0; i<S.size(); i++){
      if(S.at(i) == 'R'){
        cnt ++;
        ans = max(cnt,ans);
      }else{
        cnt = 0;
      }
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;
template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}

string board[1005];
ll dp[1005][1005];

const ll MAX = MOD;

void solve(){
  ll D,T,S; cin>>D>>T>>S;
  ll kyori = S*T;
  cout << (kyori>=D?Liny:Linn);
}

int main(int argc, char *argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG = 1;}
  solve();
  return 0;
}

Measured memory_bytes: 3640