akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define dump(x)
#define debug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long A, long long B, long long M, std::vector<long long> a, std::vector<long long> b, std::vector<long long> x, std::vector<long long> y, std::vector<long long> c){
    ll answer = *min_element(all(a)) + *min_element(all(b));
    rep(i,0,M) {
        answer = min(answer, a[x[i]-1] + b[y[i]-1] - c[i]);
    }
    cout << answer << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> a(A);
    for(int i = 0 ; i < A ; i++){
        scanf("%lld",&a[i]);
    }
    std::vector<long long> b(B);
    for(int i = 0 ; i < B ; i++){
        scanf("%lld",&b[i]);
    }
    std::vector<long long> x(M);
    std::vector<long long> y(M);
    std::vector<long long> c(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
        scanf("%lld",&c[i]);
    }
    solve(A, B, M, std::move(a), std::move(b), std::move(x), std::move(y), std::move(c));
    return 0;
}


Measured memory_bytes: 4224
// Problem : C - Maximum Volume
// Contest : AtCoder Beginner Contest 159
// URL : https://atcoder.jp/contests/abc159/tasks/abc159_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define Ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define Test Ios; int tz; cin>>tz; while(tz--)
#define prec(ans) cout<<fixed<<setprecision(20)<<ans<<'\n';
#define all(v) v.begin(), v.end()
#define F first
#define S second

#define sa(a,n)  		int a[n]; for(int zz = 0 ; zz<n; zz++) cin>>a[zz];
#define sda(a,n) 		int n; cin>>n; sa(a,n)
#define pra(a,n)        for(size_t zz=0;zz<n;zz++) cout<<a[zz]<<' '; cout<<'\n';
#define prv(a)          for(auto zz:a) cout<<zz<<' '; cout<<'\n';
#define tr1(x)          cerr <<#x<<": "<<x<<'\n';
#define tr2(x, y)       cerr <<#x<<": "<<x<<" | "<<#y<<": "<<y<<'\n';
#define tr3(x, y, z) 	cerr <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<'\n';
#define tr4(a, b, c, d) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<'\n';

int32_t main(){
//Test
{
	int l;
	cin>>l;
	double t = l/(double)3;
	double ans = t*t*t;
	prec(ans);
    
}}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;cin>>S;long K;cin>>K;
  int one=0;//先頭から連続した1の数
  for(int i=0;i<S.size();i++){
    if(S[i]!='1')break;
    one++;
  }
  if(K<=one){
    cout<<1<<endl;
  }else{
    cout<<S[one]<<endl;
  }
}

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

int main(int argc, char const *argv[])
{
	int n;
	string s;
	cin>>n>>s;
	map<pair<string,string>,int> mp;
	for (int i = 0; i < (1<<n); ++i)
	{
		string l,r;
		for (int j = 0; j < n; ++j)
		{
			if ((i>>j)&1)
			{
				l.push_back(s[j]);
			}
			else
			{
				r.push_back(s[j]);
			}
		}
		++mp[make_pair(l,r)];
	}
	long long ans=0LL;
	for (int i = 0; i < (1<<n); ++i)
	{
		string l,r;
		for (int j = 0; j < n; ++j)
		{
			if ((i>>j)&1)
			{
				r.push_back(s[j+n]);
			}
			else
			{
				l.push_back(s[j+n]);
			}
		}
		reverse(l.begin(), l.end());
		reverse(r.begin(), r.end());
		ans+=mp[make_pair(l,r)];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 87040
#include <stdio.h>

int main(void) {
  int N, M, C, ac_count = 0, point = 0;
  scanf("%d %d %d", &N, &M, &C);

  int A[N][M], B[M];

  // Bいれるやつ
  for (int i = 0; i < M; i++) {
    scanf("%d", &B[i]);
  }

  // A入れるやつ 2次元配列
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < M; j++) {
      scanf("%d", &A[i][j]);
    }
  }

  for(int i = 0; i < N; i++) {
    for(int j = 0; j < M; j++) {
      point += A[i][j] * B[j];
    }
    point += C;

    if(point > 0) {
      ac_count++;
    }

    point = 0;
  }
  printf("%d\n", ac_count);

  return 0;
}


Measured memory_bytes: 128
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<chrono>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define vint(a,n) vint a(n); rep(i, n) cin >> a[i];
#define vll(a,n) vll a(n); rep(i, n) cin >> a[i];
#define ALL(n) begin(n),end(n)
#define RALL(n) rbegin(n),rend(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
using vbool=vector<bool>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<class T>bool isprime(T n){
    if(n==2) return true;
    if(!(n&1)) return false;
    for(T i=3; i*i<=n; i+=2){if(n%i==0) return false;}
    return true;}

#define N 100005
bitset<N> primes;
void sieve(){  // nが素数ならばbitset[n]==1
    primes[0]=1; primes[1]=1;
    for(int i=4; i<N; i+=2){
        primes |= (bitset<N>(1)<<i);
    }
    for(int i=3; i<N; i+=2){
        if(!isprime(i)) continue;
        for(int j=i*3; j<N; j+=2*i){
            primes |= (bitset<N>(1)<<j);
        }
    }
    primes = ~primes;
}

int main()
{
    sieve();
    vint p(100001);
    rep(i, p.size()){
        if(i%2==0) continue;   
        p[i] = (primes[i]&primes[(i+1)/2]);
    }
    rep(i, p.size()-1) p[i+1] += p[i];

    int q; cin >> q;
    rep(i, q){
        int l, r; cin >> l >> r;
        pr(p[r] - p[l-1]);
    }
    return 0;}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int keta(int N){
    for(int i=0; i<10 ;i++){
        if(N<pow(10,i)){
            return i;
        }
    }
}

int main(){
    int N;
    cin>>N;
    int count;
    count=0;
    for(int i=0;i<N;i++){
        if(keta(i+1)%2==1){
            count++;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int rec[26];
int main()
{
    int H,W;
    scanf("%d %d",&H,&W);
    int two = 0,four = 0,one = 0;
    for(int i = 0; i < H/2; ++i)
        for(int j = 0; j < W/2; ++j)
            ++four;
 
    if(H&1 && W&1)
        two = two + H/2 + W/2;
    else if(H&1)
        two += W/2;
    else if(W&1)
        two += H/2;
 
    if(H&1 && W&1)
        one = 1;
    char ch;
    for(int i = 0; i < H; ++i)
    {
        for(int j = 0; j < W; ++j)
        {
            scanf(" %c",&ch);
            rec[ch-'a']++;
        }
    }
 
    for(int i = 0; i < 26; ++i)
    {
        while(rec[i] >= 4 && four > 0)
        {
            rec[i] -= 4;
            four--;
        }
    }
    if(four != 0)
    {
        printf("No\n");
        return 0;
    }
    for(int i = 0; i < 26; ++i)
    {
        while(rec[i] >= 2 && two > 0)
        {
            rec[i] -= 2;
            two--;
        }
    }
    if(two != 0)
    {
        printf("No\n");
        return 0;
    }
 
    int sum = accumulate(rec,rec+26,0);
    if(H&1 && W&1 && sum == 1)
        printf("Yes\n");
    else if(H&1 && W&1 && sum != 1)
        printf("No\n");
    else if(sum == 0)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var m1, d1, m2, d2 int
	fmt.Scan(&m1, &d1, &m2, &d2)
	if m1 != m2 {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <utility>
#include <algorithm>
#include <map>

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> Pll;

ll N, M;
Pll PD[10010], S[10010];

bool compare_f(Pll p, Pll q)
{
    return p.second > q.second;
}

ll DangerExpectedValue(Pll pd[], ll money, ll s)
{
    int i = 0;
    ll result = s;
    while (money > 0)
    {
        if (money >= pd[i].first)
        {
            result -= pd[i].first * pd[i].second;
        }
        else
        {
            result -= money * pd[i].second;
        }
        money -= pd[i].first;
        i++;
    }

    if (result < 0)
    {
        result = 0;
    }
    return result;
}

int main()
{
    while (cin >> N >> M && N)
    {
        ll d, p, s = 0;
        for (int i = 0; i < N; i++)
        {
            cin >> d >> p;
            PD[i] = make_pair(d, p);
            s += d * p;
        }

        sort(PD, PD + N, compare_f);

        cout << DangerExpectedValue(PD, M, s) << endl;
    }
}



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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

string ToSix(int x){
  string s = to_string(x);
  return string(max(0,6-int(s.size())),'0') + s;
}

int main(){
  int m; cin >> m;
  int n; cin >> n;
  vector<P<int,int>> v;
  vector<set<P<int,int>>> p(100001);
  for(int i = 0; i < n; ++i){
    int a,b; cin >> a >> b;
    p[a].emplace(b,i);
    v.emplace_back(a,b);
  }
  for(int i = 0; i < 100001; ++i){
    int idx = 1;
    for(auto e:p[i]){
      v[e.second].second = idx;
      idx++;
    }
  }
  for(const auto&e:v){
    cout << ToSix(e.first) + ToSix(e.second) << endl;
  }
  return 0;
}


Measured memory_bytes: 13516
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
 int a;
 cin >> a;
 if(a<1000){
     cout << "ABC"  << endl; 
 }else{
     cout << "ABD" << endl;
 }
 return 0;
}

Measured memory_bytes: 256
Imports System.Collections.Generic
Public Class Edge
  Private _Id As Integer
  Public Property Id As Integer
    Get
      Return _Id
    End Get
    Set(value As Integer)
      _Id = value
    End Set
  End Property
  Private _ToVertexId As Integer
  Public Property ToVertexId As Integer
    Get
      Return _ToVertexId
    End Get
    Set(value As Integer)
      _ToVertexId = value
    End Set
  End Property
  Public Sub New(toVertexId As Integer, id As Integer)
    Me.Id = id
    Me.ToVertexId = toVertexId
  End Sub
End Class

Public Class Program
  Shared Ans As Integer()
  Shared Sub Main()
    Dim n As Integer = Integer.Parse(Console.ReadLine())
    ReDim Ans(0 To n - 2)
    Dim graph As Dictionary(Of Integer, List(Of Edge)) = New Dictionary(Of Integer, List(Of Edge))()
    For i As Integer = 0 To n - 2
      Dim ab As Integer() = Array.ConvertAll(Of String, Integer)(Console.ReadLine().Split(" "), AddressOf Integer.Parse)
      If Not graph.ContainsKey(ab(0)) Then graph(ab(0)) = New List(Of Edge)()
      If Not graph.ContainsKey(ab(1)) Then graph(ab(1)) = New List(Of Edge)()
      graph(ab(0)).Add(New Edge(ab(1), i))
      graph(ab(1)).Add(New Edge(ab(0), i))
    Next
    Dfs(1, graph)
    Dim maxAns As Integer = 0
    For Each i As Integer In Ans
      maxAns = Math.Max(maxAns, i)
    Next
    Console.WriteLine(maxAns.ToString())
    For i As Integer = 0 To Ans.Length - 1
      Console.WriteLine(Ans(i).ToString())
    Next
  End Sub
  
  Shared Sub Dfs(current As Integer, graph As Dictionary(Of Integer, List(Of Edge)), Optional parent As Integer = -1, Optional color As Integer = -1)
    Dim k As Integer = 1
    For Each nodes As Edge In graph(current)
      Dim toVertexId As Integer = nodes.ToVertexId
      Dim id As Integer = nodes.Id
      If Not toVertexId = parent Then
        If k = color Then k += 1
        Ans(id) = k
        k += 1
        Dfs(toVertexId, graph, current, Ans(id))
      End If
    Next
  End Sub
End Class

Measured memory_bytes: 49588
N = int(input())
AS = input().split()
AS = [int(i) for i in AS]
BS = [int(AS[j-1] - j) for j in range(1,N+1)]
BS_s = BS.sort()
b = BS[N//2]
result_a = 0
result_b = 0
result_c = 0
for j in range (1, N+1):
    result_a += abs(int(AS[j-1]) - b - j)
for j in range (1, N+1):
    result_b += abs(int(AS[j-1]) - b - 1 - j)
for j in range (1, N+1):
    result_c += abs(int(AS[j-1]) - b + 1 - j)
print (int(min(result_a,result_b,result_c)))

Measured memory_bytes: 26016
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int N;

int f(int X){
	int x = 0;
	while(X){
		x += X % 10;
		X /= 10;
	}
	return x;
}
void solve(){
	cout << (N % f(N) ? "No" : "Yes") << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N;
		solve();
	return 0;
}


Measured memory_bytes: 256
n = int(input())
li = [int(x) for x in input().split()]

dp = [float("inf")]*n
dp[0] = 0
dp[1] = abs(li[1]-li[0])
for i in range(2,n):
    dp[i] = min(dp[i-1]+abs(li[i]-li[i-1]),dp[i-2]+abs(li[i]-li[i-2]))
print(dp[n-1])

Measured memory_bytes: 53616
n,y = map(int,input().split())
c=0
for i in range(n+1):
  if c == 1:
    break
  x = y - 10000*i
  a = n - i
  for j in range(a+1):
    z = x - 5000*j
    k = a - j
    if k == (z/1000):
      print(i,j,k)
      c = 1
      break
if c == 0:
  print(-1,-1,-1)

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> a(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> a.at(i).at(j);
    }
  }
  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }
  cout << endl;
  for (int i = 0; i < H; i++) {
    cout << "#";
    for (int j = 0; j < W; j++) {
      cout << a.at(i).at(j);
    }
    cout << "#" << endl;
  }
  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }
  cout << endl;
}


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

int main(){
	
	int n, l;
	
	cin >> n >> l;
	
	int a[n];
	
	for (int i = 0; i < n; i++){
		a[i] = l + i;
	}
	
	sort(a, a+n);
	
	int ans = 0;
	
	if (l > 0){
		for (int i = 1; i < n; i++){
			ans+=a[i];
		}
	} else if (abs(n)-abs(l) > 0){
		for (int i = 0; i < n; i++){
			ans+=a[i];
		}
	} else if (abs(n)-abs(l) <= 0){
		for (int i = 0; i < n-1; i++){
			ans+=a[i];
		}
	}
	
	cout << ans;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
int main(){
    int n;
    char c;
    while(cin>>c){
    	if(c>='a' && c<='z'){
    		cout<<'a'<<endl;
    	}
    	else{
    		cout<<'A'<<endl;
    	}
    }
  return 0;
}




Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
struct SegTree {
    int N;
    vector<int> A;
    SegTree(int n) {
        N = 1; while (N < n) N *= 2;
        A.resize(2 * N);
    }
    void add(int L, int R, int val) {
        L += N, R += N;
        while (L < R) {
            if (L & 1) A[L++] += val;
            if (R & 1) A[--R] += val;
            L /= 2, R /= 2;
        }
    }
    int get(int idx) {
        idx += N;
        int ans = 0;
        while (idx > 0) {
            ans += A[idx];
            idx /= 2;
        }
        return ans;
    }
};
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N, M; cin >> N >> M;
    vector<int> ans(M + 2);
    vector<vector<pair<int, int>>> A(M + 1);
    for (int i = 0; i < N; i++) {
        int a, b; cin >> a >> b;
        A[b - a].emplace_back(a, b);
        ans[1] += 1;
        ans[b - a + 1] -= 1;
    }
    for (int i = 1; i <= M; i++) {
        ans[i] += ans[i - 1];
    }
    SegTree st(M + 1);
    for (int i = 1; i <= M; i++) {
        for (auto &p : A[i - 1]) {
            st.add(p.first, p.second + 1, 1);
        }
        for (int t = 0; t <= M; t += i) {
            ans[i] += st.get(t);
        }
    }
    for (int i = 1; i <= M; i++) cout << ans[i] << '\n';
    return 0;
}


Measured memory_bytes: 9088
#include<algorithm>
#include<cmath>
#include<cstdint>
#include<cstdio>
#include<functional>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
using namespace std;

#define loop(i,a,b) for(int i=(a); i<(b); ++i)
#define rep(i,n) for(int i=0; i<n; ++i)
#define all(v) begin(v), end(v)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

const double PI = acos(-1.0);

int main() {
  std::ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  cout << min({a + b, a + c, b + c}) << endl;
  return 0;
}


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

void code()
{
    ll n;
    cin>>n;
    cout<<n+n*n+n*n*n<<endl;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    while(t--)
    {
        code();
    }
}

Measured memory_bytes: 3592
n,x = map(int, input().split())
l = list(map(int, input().split()))
d = [0]*(n+1)
ans = 1
for i in range(1,n+1):
    d[i] = d[i-1] + l[i-1]
    if d[i]<=x:
        ans += 1
    else:
        print(ans)
        exit()
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
const ll mod=13;
const ll MOD = 1e9 + 7;

int main()
{
	string s;
	cin >> s;
	ll n = s.size();

	vector<vector<ll>> dp(n, vector<ll>(mod, 0));
	if (s[0] == '?') for (int i = 0; i < 10; i++) dp[0][i] = 1;
	else dp[0][(s[0] - '0')%mod] = 1;

	for (int i = 1; i < n; i++)
	{
		if (s[i] == '?')
		{
			for (int k = 0; k < 10; k++)
			{
				for (int j = 0; j < mod; j++)
				{
					dp[i][(j * 10 + k) % mod] += dp[i - 1][j];
				}
			}
		}
		else
		{
			for (int j = 0; j < mod; j++)
			{
				dp[i][(j*10+(s[i] - '0')) % mod] += dp[i - 1][j];
			}
			
		}
		for (int j = 0; j < mod; j++) dp[i][j] %= MOD;
	}
	cout << dp[n - 1][5];
}

Measured memory_bytes: 13568
x, y, z, k = map(int, input().split())

A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

bc = []

for b in B:
    for c in C:
        bc.append(b+c)

bc.sort(reverse=True)
t = min(len(bc), 3333)
bc = bc[:t]
cnt = 0
cand = []

for a in A:
    cnt = 0
    for i in bc:
        cnt += 1
        cand += [a + i]
        if cnt == 3000:
            break

cand.sort(reverse=True)
cnt = 0
for i in cand:
    print(i)
    cnt += 1
    if cnt == k:
        break


Measured memory_bytes: 159544
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 10000000000000000
int main(){
	int n;cin>>n;
	
	vector<pair<pair<string,int>,int>> P(n);

	for(int i=0;i<n;i++){
		cin>>P[i].first.first>>P[i].first.second;
		P[i].first.second*=(-1);
		P[i].second=i+1;
	}
	sort(P.begin(),P.end());//pair<string,int>でsort-> (b,-1),(a,-9),(a,-2)は(a,-2),(a,-9),(b,-1)になる

	for(int i=0;i<n;i++){
		cout<<P[i].second<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int d[] = new int[n];
        for(int i=0;i<n;i++) {
            d[i] = in.nextInt();
        }
        for(int i=n-1;i>=0;i--) {
            if(i == 0) {
                System.out.println(d[i]);
            } else {
                System.out.print(d[i] + " ");
            }
        }
    }
}

Measured memory_bytes: 26104
#include <iostream>
#include <cstring>
using namespace std;
int N;
string s;

int check(int index){
  string a,b;
  a=s.substr(0,index);
  b=s.substr(index,N-index);
  bool cnta[26],cntb[26];
  for (int i=0;i<26;i++){
    cnta[i]=false;
    cntb[i]=false;
  }
  for (int i=0;i<a.length();i++)
    cnta[a[i]-'a']=true;
  for (int i=0;i<b.length();i++)
    cntb[b[i]-'a']=true;
  int ans=0;
  for (int i=0;i<26;i++)
    if (cnta[i] && cntb[i])
      ans++;
  return ans;
}

int main()
{
  cin>>N>>s;
  int ans=0;
  for (int i=1;i<N;i++)
    ans=max(ans,check(i));
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>


int main() {
    int h, m, s;
    scanf("%d", &s);
    m = s / 60;
    s = s % 60;
    h = m / 60;
    m = m % 60;
    printf("%d:%d:%d\n", h, m, s);
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
a = [int(x) for x in input().split()]

cumulative_sum = []
cnt = 0
for i in range(n):
    cnt += a[i]
    cumulative_sum.append(cnt)

ans = abs(cumulative_sum[0] - (cumulative_sum[-1] - cumulative_sum[0]))
for i in range(n - 1):
    ans = min(abs(cumulative_sum[i] - (cumulative_sum[-1] - cumulative_sum[i])), ans)

print(ans)

Measured memory_bytes: 24828
#include <stdio.h>

int main() {
  int H=0,W=0,i,j,k,max=0,tmp=0;
  scanf("%d%d", &H, &W);
  char S[H][W];
  int R[H][W],L[H][W],D[H][W],U[H][W];
  for(i=0;i<H;i++) scanf("%s",S[i]);

  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      if(S[i][j]=='.') tmp++;
      else tmp=0;
      R[i][j]=tmp;
      if(j==W-1) tmp=0;
    }
  }

  for(i=0;i<H;i++){
    for(j=W-1;j>=0;j--){
      if(S[i][j]=='.') tmp++;
      else tmp=0;
      L[i][j]=tmp;
      if(j==0) tmp=0;
    }
  }

  for(j=0;j<W;j++){
    for(i=0;i<H;i++){
      if(S[i][j]=='.') tmp++;
      else tmp=0;
      D[i][j]=tmp;
      if(i==H-1) tmp=0;
    }
  }

  for(j=0;j<W;j++){
    for(i=H-1;i>=0;i--){
      if(S[i][j]=='.') tmp++;
      else tmp=0;
      U[i][j]=tmp;
      if(i==0) tmp=0;
    }
  }

  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      tmp=R[i][j]+L[i][j]+D[i][j]+U[i][j]-3;
      if(tmp>max) max=tmp;
    }
  }
  
  printf("%d\n",max);

  return 0;
}


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

int main(void){

	int k_prc, t_prc, k_cal, num;

	cin >> num >> k_prc >> t_prc >> k_cal;

	vector<int> v;

	for(int i = 0; i < num; i++){
		int a;
		cin >> a;
		v.push_back(a);
	}
	sort(v.begin(), v.end(), greater<int>());
	int max_cal = k_cal / k_prc;
	int cnt = 1;
	while(1){
		float cal = (float)k_cal;
		int sum_prc = 0;
		for(int i = 0; i < cnt; i++){
			cal += (float)v[i];
		}
		sum_prc = k_prc + (t_prc*cnt);
		cal /= (float)sum_prc;
		if(max_cal < cal){max_cal = cal;}
		if(cnt == num){break;}
		cnt++;
	}
	cout << max_cal << endl;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main(){
  int N;
  cin >> N ;
  vector<int> a(N+2);
  a.at(0) = 0;
  a.at(N+1) = 0;
  for(int i = 1; i<= N; i++){
    cin >> a.at(i);
  }
  int b = 0;
  for(int i = 0; i <= N; i++){
    b+= abs(a.at(i)-a.at(i+1));
  }
  int c[1000000]={0};
  for(int i = 1; i<=N; i++){
    c[i] += b - abs(a.at(i)-a.at(i-1))-abs(a.at(i)-a.at(i+1)) + abs(a.at(i-1)-a.at(i+1));
  }
  for(int i = 1; i<=N; i++){
    cout << c[i] << endl;
  }
}



Measured memory_bytes: 5504
package main

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

// const abcd = "abcdefghijklmnopqrstuvwxyz"
// const ABCD = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

// var dy = [...]int{1, 1, 0, -1, -1, -1, 0, 1}
// var dx = [...]int{0, 1, 1, 1, 0, -1, -1, -1}

// var dx = [...]int{0, 1, 0, -1}
// var dy = [...]int{1, 0, -1, 0}

var inf int = 1e13
var mod = 1000000007

// ---------------------------------------------------------
func main() {
	log.SetFlags(log.Lshortfile)
	next := newScanner()
	s := next.next()
	d := make([]byte, 0)
	for i := 0; i < len(s); i++ {
		if s[i] != 'x' {
			d = append(d, s[i])
		}
	}

	ans := 0
	for i := 0; i < len(d)/2; i++ {
		if d[i] != d[len(d)-1-i] {
			ans = -1
			break
		}
	}
	if ans == 0 {
		i := 0
		j := len(s) - 1
		for i < j {
			if s[i] != s[j] {
				if s[i] == 'x' {
					i++
					ans++
				}
				if s[j] == 'x' {
					j--
					ans++
				}
			} else {
				i++
				j--
			}
		}
	}

	fmt.Println(ans)
}

// ---------------------------------------------------------

// Pair is liked C++ pair
type Pair struct {
	a, b int
}

// Pairs is sorted by []Pair struct
type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a < p[j].a {
		return true
	} else if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return false
}

// -------------------------------
func in(c, a, z int) bool {
	return c >= a && c < z
}

func btoi(b bool) int {
	if b {
		return 1
	}
	return 0
}

func itob(a int) bool {
	if a == 0 {
		return false
	}
	return true
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func sum(a ...int) int {
	r := a[0]
	if len(a) > 1 {
		for i := 1; i < len(a); i++ {
			r += a[i]
		}
	}
	return r
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// ---------- buffered scanner -----------------------------------------
type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 10000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) Line() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) Int() int {
	v, _ := strconv.Atoi(s.next())
	return v
}
func (s *scanner) Int64() int64 {
	v, _ := strconv.ParseInt(s.next(), 10, 64)
	return v
}
func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 1792
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (h, w) = get!(usize, usize);
    let mut r = vec![vec!['#'; w+2]; h+2];
    let mut aa = Vec::new();
    for _ in 0..h {
        aa.push(get!(String).chars().collect::<Vec<_>>());
    }
    for i in 0..h {
        for j in 0..w {
            r[i+1][j+1] = aa[i][j];
        }
    }
    for a in r.into_iter() {
        println!("{}", a.into_iter().collect::<String>())
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <tuple>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
using namespace std;
void init();
#define REP(var, num) for(sll var = 0; var < num; var++)
typedef signed long long sll;
typedef unsigned long long ull;
/*
numeric_limits<sll>::max()
*/

sll dp[101][100001];

int main() {
    init();
    sll n, total_cap;
    cin >> n >> total_cap;

    REP(c, total_cap) {
        dp[0][c] = 0;
    }

    vector<sll> ws(n);
    vector<sll> vs(n);
    for (sll i = 0; i < n; i++) {
        cin >> ws[i] >> vs[i];
    }

    for (sll i = 0; i < n; i++) {
        for (sll cap = 0; cap <= total_cap; cap++) {
            if (cap >= ws[i]) {
                dp[i+1][cap] = max(dp[i][cap - ws[i]] + vs[i], dp[i][cap]);
            } else {
                dp[i+1][cap] = dp[i][cap];
            }
        }
    }

    cout << dp[n][total_cap] << endl;
    return 0;
}

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

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

int main() {
  int N; cin >> N;
  vector<int> p(N);
  for (int i = 0; i < N; i++) {
    int n; cin >> n;
    n--;
    p.at(i) = n;
  }
  int cnt = 0;
  bool flag = false;
  for (int i = 0; i < N; i++) {
    if (p.at(i) == i) {
      if (flag) {
        cnt++;
        flag = false;
      }
      else {
        flag = true;
      }
    }
    else {
      if (flag) {
        cnt++;
        flag = false;
      }
    }
  }
  if (flag) cnt++;
  cout << cnt << endl;
}

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

typedef long long ll;
typedef vector<ll> v1;

typedef vector<vector<ll>> graph;

const ll INF = 1ll << 50;
const ll mod = 1000000007;

string s;
string rs;
ll ans;

int main(){
    cin >> s;
    rs = s;
    reverse(rs.begin(),rs.end());
    for(ll i = 0;i < s.size();i++){
        if(rs[i] != s[i]) ans++;
    }

    cout << ans/2<< endl;
}


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

int main(){
    int n,m,l;
    cin >> n >> m >> l;
    vector<vector<int> > a(n,vector<int>(m));
    vector<vector<int> > b(m,vector<int>(l));
    vector<vector<long long> > c(n,vector<long long>(l,0));
    rep(i,n) rep(j,m) cin >> a[i][j];
    rep(j,m) rep(k,l) cin >> b[j][k];
    rep(i,n) rep(j,m) rep(k,l)
                c[i][k] += a[i][j] * b[j][k];
    rep(i,n){ 
        rep(k,l){ 
            cout << c[i][k];
            if(k < l-1) cout << " ";
        }
        cout << endl;
    }
    return 0;
}



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

using namespace std;

struct Edge {
	int a, b, cost;
};

int n, m;
int root[100], high[100];
Edge e[10000];

void init(int n) {
	for (int i = 0; i < n; i++)root[i] = i, high[i] = 1;
}

int getroot(int n) {
	if (n == root[n])return n;
	return root[n] = getroot(root[n]);
}

bool issame(int a, int b) {
	return getroot(a) == getroot(b);
}

void unite(int a, int b) {
	a = getroot(a), b = getroot(b);
	if (a == b)return;
	if (high[a] > high[b])root[b] = a;
	else if (high[a] < high[b])root[a] = b;
	else root[a] = b, high[a]++;
}

int main() {
	while(cin >> n ,n ){
		cin >> m;
		for (int i = 0; i < m; i++) {
			char c;
			cin >> e[i].a >> c >> e[i].b >> c >> e[i].cost;
			e[i].cost = e[i].cost / 100 - 1;
		}
		sort(e, e + m, [](Edge &l, Edge &r) {
			return l.cost < r.cost;
		});
		int ans = 0;
		init(n);
		for (int i = 0; i < m; i++) {
			if (!issame(e[i].a, e[i].b)) {
				unite(e[i].a, e[i].b);
				ans += e[i].cost;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3152
//Volume1-0113
import java.util.*;

public class Main {

    public static void main(String[] args) {

    	//declare
    	int     p,q,quo,rem;
    	String  ans,rec_p;
    	boolean rec;
    	ArrayList<Integer> Rem = new ArrayList<Integer>();
    	
    	//input
    	Scanner sc = new Scanner(System.in);
    	while(sc.hasNext()){
    		p = sc.nextInt();
    		q = sc.nextInt();
    		
    		//initialize
    		Rem.clear();
    		rem = p%q;
    		p   = rem*10;
    		Rem.add(rem);
    		ans = "";
    		
    		//calculate
    		while(true) {
    			quo = p/q;
    			rem = p%q;
    			ans += quo;
    			if(Rem.contains(rem)){rec = true;  break;}
    			if(rem == 0)         {rec = false; break;}
    			Rem.add(rem);
    			p = rem*10;
    		}
    		//output
    		System.out.println(ans);
    		if(rec){
	    		rec_p = "";
    			for(int i=0;i<ans.length();i++){
    				if   (i>=Rem.indexOf(rem)){rec_p += "^";}
    				else                      {rec_p += " ";}
    			}
    			System.out.println(rec_p);
    		}
    	}
    }
}

Measured memory_bytes: 23668
n,l=map(int,input().split())
a=list(map(int,input().split()))
m=0
x=0
for i in range(n-1):
  if((a[i]+a[i+1])>=m):
    m=a[i]+a[i+1]
    x=i
if(m<l):
  print("Impossible")
else:
  print("Possible")
  for j in range(x):
    print(j+1)
  for k in range(n-1,x+1,-1):
    print(k)
  print(x+1)

Measured memory_bytes: 14064
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))
import math
def main():
    a, b, x = input_nums()
    h = x / a**2
    if 2*h-b >= 0:
        print(math.degrees(math.atan((2*b-2*h)/a)))
    else:
        w = (2*a*h)/b
        print(math.degrees(math.atan(b/w)))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
class road {
public:
	char thatlevel;
	char information;
	int time;
	road() :thatlevel('0'), information('X') {

	}
};
int main() {
	int H, W, N;
	queue<pair<short, short> > date;
	cin >> H >> W >> N;
	vector<vector<road> > map(W + 2, vector<road>(H + 2));
	for (int y = 1; y <= H; ++y) {
		for (int x = 1; x <= W; ++x) {
			cin >> map[x][y].information;
			if (map[x][y].information == 'S') {
				date.push(pair<short, short>(x, y));
				map[x][y].time = 0;
			}
		}
	}
	int answer = -1;
	short x, y;
	pair<short, short> dummy;
	char nlevel = '1';
	char movex[]{ 0,1,0,-1 }, movey[]{ 1,0,-1,0 };
	road *floor;
	while (answer < 0) {
		dummy = date.front();
		date.pop();
		x = dummy.first;
		y = dummy.second;
		for (int i = 0; i < 4; ++i) {
			floor = &map[x + movex[i]][y + movey[i]];
			if (floor->information == 'X')continue;
			if (floor->thatlevel < nlevel) {
				floor->thatlevel = nlevel;
				floor->time = map[x][y].time + 1;
				if (nlevel==floor->information) {
					++nlevel;
					floor->information = '.';
					if (nlevel == N + 1 + '0') {
						answer = floor->time;
					}
					queue<pair<short, short> > empty;
					swap(date, empty);
					date.push(pair<short, short>(x + movex[i], y + movey[i]));
					break;
				}
				date.push(pair<short, short>(x + movex[i], y + movey[i]));
			}
		}
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 10676
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

using namespace std;
typedef long long ll;

int main() {
  string S, T;
  cin >> S >> T;
  int count = 0;
  int m = 0;
  //cout << S.size() << endl;
  //cout << T.size() << endl;
  for (int i=0; i <= S.size() - T.size(); i++) {
    for (int j=0; j < T.size(); j++) {
      if (S[i+j] == T[j])count++;
    }
    m = max(m, count);
    count=0;
  }
  cout << T.size()-m << endl;
  return 0;
}


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

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define REP64(i, s,  n) for(int64 i = s;i < (n);i++)
#define INF 999999999
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

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

//---------------------------------------------------------------
// 別解　考えやすい
//---------------------------------------------------------------

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	string s;
	cin >> s;
	int N = s.size();
	
	int wc = 0;
	int64 wi = 0;
	// 白の数と初期座標の合計を求める
	REP(i, 0, N)	if (s[i] == 'W') {
		wi += i;
		wc++;
	}
//	cout << "count = " << wc << endl;

	int64 we = 0;
	// 白の最終座標の合計を求める
	REP(i, 0, wc)	we += i;

	// 座標の変化量を計算する
	int64 ans = wi - we;
//	cout << "init = " << wi << "  end = " << we << endl;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
// #pragma GCC optimize("O2")
typedef long long int ll;
typedef long double ld;
typedef map <ll,ll> mm;
typedef vector <ll> mv;
typedef pair <ll,ll> mp;
typedef set <ll> ms;
typedef multiset <ll> mms;
typedef queue <ll> mq;
typedef deque <ll> mdq;
typedef stack <ll> mst;
typedef priority_queue <ll> mpq;
typedef priority_queue <ll, vector<ll>, greater<ll> > mmh;
typedef complex<double> cd;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define flush cout.flush();
#define all(v) v.begin(),v.end()
#define deb(x) cout << #x << " " << x << endl;
#define ff first
#define ss second
#define pb(v) push_back(v)
#define lb(v) lower_bound(v)
#define ub(v) upper_bound(v)
#define cn continue
#define forl(i,n) for(ll i=0;i<n;i++)
#define forlr(i,n) for(ll i=n-1;i>=0;i--)
#define rev(s) reverse(s.begin(),s.end())
void swap(ll &a,ll &b) {
	ll tmp=a;
	a=b;
	b=tmp;
}
ll atoistring(string s) {
	stringstream lol(s);
	ll x;
	lol>>x;
	return x;
}
void pv(mv v) {
	forl(i,v.size()) cout<<v[i]<<" ";
	cout<<"\n";
}
void pa(ll *v, ll size) {
	forl(i,size) cout<<v[i]<<" ";
	cout<<"\n";
}
void removeDups(mv &v) {
	sort(all(v));
	mv::iterator it = unique(v.begin(), v.end());
	v.resize(distance(v.begin(), it));
}
inline ld kthRoot(ld n, ll k) {
	return pow(k, (1.0 / k) * (log(n) / log(k)));
}
ll power(ll x, ll y, ll p) {
	ll res=1;
	x=x%p;
	while(y>0) {
		if(y&1) res = (res*x)%p;
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
void checkmod(ll &x, ll mod) {
	if(x>=mod) x%=mod;
}

ll mod = 1e9 + 7;

mm mapp1, mapp2;
mv arr[300005];
void thisIsMain() {
	ll h, w, m;
	cin>>h>>w>>m;
	forl(i,m) {
		ll x1, y1;
		cin>>x1>>y1;
		mapp1[x1] ++ ;
		mapp2[y1] ++ ;
		arr[x1].pb(y1);
	}
	// forl(i,300001) {
	// 	for(auto v : arr[i]) cout<<i<<" "<<v<<"\n";
	// }
	ll maxi1 = 0, maxi2 = 0, cnt = 0;
	for(auto v : mapp1) maxi1 = max(maxi1, v.ss);
	for(auto v : mapp2) maxi2 = max(maxi2, v.ss);
	for(auto v : mapp2) cnt += (maxi2 == v.ss);
	forl(i,300001) {
		if(arr[i].empty() || mapp1[i] != maxi1) cn;
		ll tmpcnt = 0;
		for(auto v : arr[i]) tmpcnt += (mapp2[v] == maxi2);
		if(tmpcnt < cnt) {
			// cout<<"yo\n";
			cout<<maxi1 + maxi2<<"\n";
			return ;
		}
	}
	cout<<maxi1 + maxi2 - 1<<"\n";
}

int main(void)
{
	fastio
	ll t = 1;
	// cin>>t;
	while(t--) thisIsMain();
	return 0;
}

Measured memory_bytes: 57528
program main
implicit None
	integer(8)::n,p,a(9),s(9,262144),b(262144),i,c,x,y,z,L,d,w
	
	read *,c
	s = 0
	do n = 1,262143
		call tet(n,a)
		s(:,n) = a
	enddo
	
	s = (1-((8-(s*2+1))/7))*(s*2+1)
	
	b = 0
	do n = 1,262143
		do i = 1,9
			b(n) = b(n) + s(i,n)*(10**(i-1))
		enddo
	enddo
	
	p = 0
	n = 1
	
	do while(n < 262145)
		if (b(n) > c) exit
		x = 0;y = 0;z = 0;w = 1
		d = b(n)
		L = int(log10(real(d)))+1
		do i = L,1,-1
			if(d/10**(i-1) == 7)then
				x =1
				d = d - 7 * 10**(i-1)
				else if(d/10**(i-1) == 5)then
				y =1
				d = d - 5 * 10**(i-1)
				else if(d/10**(i-1) == 3)then
				z =1
				d = d - 3 * 10**(i-1)
				else if(d/10**(i-1) == 0)then
				w = 0
				exit
			endif
		enddo
		
		!print 101,b(n),L,x,y,z,w
		if(x ==1 .and. y == 1 .and. z ==1 .and. w == 1)then
			p = p + 1
		endif
		n = n + 1
	enddo
	
	print *,p
101 format(8(i0,1x))
end program main
 
subroutine tet(n,a)
	integer(8)::n,i,p
	integer(8)::a(9)
	
	a = 0
	p = n
	i = 1
	do while (p /= 0)
		a(i) = mod(p,4)
		p = p/4
		i = i + 1
	enddo
end subroutine tet

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

int main() {
  vector<long long> count(100001);
  int N;
  long long s = 0;
  cin >> N;
  for(int i = 0; i < N; i++) {
    int a;
    cin >> a;
    count.at(a)++;
    s += a;
  }
  
  int Q;
  cin >> Q;
  for(int i = 0; i < Q; i++) {
    int B, C;
    cin >> B >> C;
    s -= (B - C) * count[B];
    count[C] += count[B];
    count[B] = 0;
    cout << s << endl;
  }
}


Measured memory_bytes: 3884
let split_string ?(pattern="") = Str.split @@ Str.regexp pattern
let (h, w) = Scanf.sscanf (read_line ()) "%d %d" @@ fun h w -> (h, w)
let s = Array.init h @@ fun _ -> read_line () |> split_string |> Array.of_list

let rec start i j = if s.(i).(j) = "." then (i, j) else if j = w - 1 then start (i + 1) 0 else start i (j + 1)
let (si, sj) = start 0 0

let walk i j arr =
  let que = Queue.create () in
  Queue.add (i, j) que;
  while not (Queue.is_empty que) do
    let (i, j) = Queue.pop que in
    List.iter (fun (di, dj) -> 
      if 0 <= di && di < h && 0 <= dj && dj < w && s.(di).(dj) = "."  && arr.(di).(dj) = -1 then begin
        arr.(di).(dj) <- arr.(i).(j) + 1;
        Queue.add (di, dj) que
      end
    ) [(i - 1, j); (i + 1, j); (i, j - 1); (i, j + 1)]
  done

let f arr =
  let m = ref 0 in
  for i = 0 to h - 1 do
    for j = 0 to w - 1 do
      m := max !m arr.(i).(j)
    done
  done;
  !m

let () =
  let ans = ref 0 in
  for i = 0 to h - 1 do
    for j = 0 to w - 1 do
      if s.(i).(j) = "." then begin
        let arr = Array.init h @@ fun _ -> Array.make w (-1) in
        arr.(i).(j) <- 0;
        walk i j arr;
        ans := max !ans (f arr)
      end
    done
  done;
  Printf.printf "%d\n" !ans

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
char s[200005];
int main()
{
    scanf("%s",s);
    int sum=0;
    for(int i=0;s[i];i++)
    {
        sum+=s[i]-'0';
    }
    if(sum%9==0) printf("Yes\n");
    else printf("No\n");
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string temp[] = { "dream","dreamer","erase","eraser" };
	rep(i, 0, 4)reverse(all(temp[i]));

	string S;
	cin >> S;
	reverse(all(S));

	int p = 0;
	while (p < SZ(S))
	{
		bool ok = false;
		rep(i, 0, 4)
		{
			if (S.substr(p, SZ(temp[i])) == temp[i])
			{
				ok = true;
				p += SZ(temp[i]);
				break;
			}
		}
		if (!ok)
		{
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String b = sc.next();
		if (b.equals("A")){
			System.out.println("T");
		} else if (b.equals("T")){
			System.out.println("A");
		} else if (b.equals("C")){
			System.out.println("G");
		} else if (b.equals("G")){
			System.out.println("C");
		}
	}
}

Measured memory_bytes: 20948
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		String line = in.next();
		char ch[] = line.toCharArray();
		for(int i=line.length(); i>0; i--){
			System.out.print(ch[i-1]);
		}
		System.out.println();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
#define debug(x) cerr << #x << "=" << x << endl;
#define lgx cerr << "-----------" << endl;

int main() {
	char a, b;
		cin >> a >> b;
		if(a < b) printf("<\n");
		else if(a > b) printf(">\n");
		else cout << "=" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			String inverseTrigonometricTop = sc.next();//逆三角の一番上
			String inverseTrigonometricBottom = "";
			while(inverseTrigonometricTop.length() > 1){
				for(int i=0;i<inverseTrigonometricTop.length()-1;i++){
					int temp = 0;
					if((temp = Integer.parseInt("" + inverseTrigonometricTop.charAt(i)) +
							   Integer.parseInt("" + inverseTrigonometricTop.charAt(i + 1)))
						     >= 10){
						temp -= 10;
					}
					inverseTrigonometricBottom = inverseTrigonometricBottom + temp;
				}
				inverseTrigonometricTop = inverseTrigonometricBottom;
				inverseTrigonometricBottom = "";
			}
			System.out.println(inverseTrigonometricTop);
		}
	}
}

Measured memory_bytes: 12000
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

const string ur = "UNRESTORABLE";

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S_d, T;
  cin >> S_d >> T;

  bool ok = false;
  string S = S_d;
  int t_size = T.size();

  for (int i = S_d.size() - 1; i >= t_size - 1; i--) {
    bool match = true;
    int j = i - t_size + 1, k = 0;
    while (k < t_size) {
      if (S_d[j] != T[k] && S_d[j] != '?') {
        match = false;
        break;
      }
      j++;
      k++;
    }

    if (match) {
      S.replace(i - t_size + 1, t_size, T);
      ok = true;
      break;
    }
  }

  if (ok) {
    for (int i = 0; i < S.size(); i++) {
      if (S[i] == '?') {
        S[i] = 'a';
      }
    }
    cout << S << endl;
  } else {
    cout << ur << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main () {
  string str;
  int m;
  while(cin >> str, str != "-"){
  cin >> m;
  for(int i = 0; i < m ; i++){
    int d;
    cin >> d;
    string str2;
    copy(str.begin()+d, str.end(), back_inserter(str2));
    copy(str.begin(), str.begin()+d, back_inserter(str2));
    str = str2;
  }
  cout << str << endl;
  }
}

Measured memory_bytes: 3144
N, X, Y = list(map(int, input().split()))

dist_cnt = [0]*N

for i in range(1, N):
    for j in range(i+1, N+1):
        dist = min([j-i, abs(i - X) + abs(j - Y) + 1])
        dist_cnt[dist] += 1

for i in range(1, N):
    print(dist_cnt[i])

Measured memory_bytes: 9216