akhauriyash/Code-Regression huggingface dataset:
#include<string>
#include<iostream>
#include<map>
using namespace std;
const long long p=1000000007;
long long n;
map<long long,long long> f;
long long dp(long long x)
{
	if(f[x]) return f[x];
	else return f[x]=(dp(x/2)%p+dp((x-1)/2)%p+dp((x-2)/2)%p)%p;
}
int main(){
	f[0]=1;
	f[1]=2;
	cin>>n;
	cout<<dp(n);
}

Measured memory_bytes: 384
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vvi root(n);
  rep(i, m){
    int a,b;
    cin >> a >> b;
    a--; b--;
    root[a].push_back(b);
    root[b].push_back(a);
  }
  queue<int> que;
  que.push(0);
  vi checked(n, -1);
  checked[0] = 0;
  while(!que.empty()){
    int pos = que.front();
    que.pop();
    if(pos == n - 1){
      if(checked[pos] == 2) cout << "POSSIBLE" << endl;
      else cout << "IMPOSSIBLE" << endl;
      return 0;
    }
    for(int a : root[pos]){
      if(checked[a] == -1){
        checked[a] = checked[pos] + 1;
        que.push(a);
      }
    }
  }
  cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 13168
#include <stdio.h>
#include <stack>
#include <math.h>

using namespace std;

struct Point{
	double x,y;
};

int main(){

	double c1x,c1y,c1r,c2x,c2y,c2r,dist;

	scanf("%lf %lf %lf",&c1x,&c1y,&c1r);
	scanf("%lf %lf %lf",&c2x,&c2y,&c2r);

	dist = sqrt((c1x-c2x)*(c1x-c2x)+(c1y-c2y)*(c1y-c2y));

	if(dist > c1r + c2r){
		printf("4\n");
	}else if(fabs(dist - (c1r+c2r)) < 0.00000001){
		printf("3\n");
	}else{
		if(c1r > c2r){
			if(dist < c1r){
				if(fabs(c1r-(dist+c2r)) < 0.00000001){
					printf("1\n");
				}else{
					if(dist < (c1r-c2r)){
						printf("0\n");
					}else{
						printf("2\n");
					}
				}

			}else{
				printf("2\n");
			}

		}else{
			if(dist < c2r){
				if(fabs(c2r-(dist+c1r)) < 0.00000001){
					printf("1\n");
				}else{
					if(dist < (c2r-c1r)){
						printf("0\n");
					}else{
						printf("2\n");
					}
				}
			}else{
				printf("2\n");
			}
		}

	}

    return 0;
}



Measured memory_bytes: 2752
import java.util.Arrays;
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        for(int i = 0;i < N;i++){
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        System.out.println(a[N-1] - a[0]);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;
typedef long long ll;

const int    INF = 1000000000;
const int    MOD = 1000000007;
const double EPS = 1e-8;

inline bool valid(int x, int y, int W, int H){
    return x >= 0 && y >= 0 && x < W && y < H;
}

int encode(int x[4], int y[4]){
    int s = 0;
    for(int i = 0; i < 4; i++){
        s = (s << 8) | (x[i] << 4) | y[i];
    }
    return s;
}
void decode(int s, int x[4], int y[4]){
    for(int i = 3; i >= 0; i--){
        x[i] = (s >> 4) & 0xf;
        y[i] = s & 0xf;
        s >>= 8;
    }
}

int main(){
    int W, H;
    while(cin >> W >> H && W){
        char grid[30][30];
        REP(i, H) cin >> grid[i];
        int sx[4], sy[4];
        int rid = 1;
        REP(y, H) REP(x, W) if(grid[y][x] == '@'){ sx[0] = x, sy[0] = y; grid[y][x] = '.';
            REP(y, H) REP(x, W) if(grid[y][x] == '*'){ sx[rid] = x; sy[rid] = y; rid++; grid[y][x] = '.'; }
        }
        int start = encode(sx, sy);
        queue<int> que;
        map<int, int> dist;
        que.push(start);
        dist[start] = 0;
        while(!que.empty()){
            int s = que.front(); que.pop();
            int x[4], y[4];
            decode(s, x, y);
            bool goal = true;
            for(int i = 1; i < 4; i++) if(grid[y[i]][x[i]] != '_') goal = false;
            /*
            REP(i, 4) grid[y[i]][x[i]] = '1' + i;
            REP(y, H) cout << grid[y] << endl;
            cout << endl;
            REP(i, 4) grid[y[i]][x[i]] = '.';
            */
            if(goal){
                cout << dist[s] << endl;
                break;
            }
            const int dx[4] = {1, 0, -1, 0};
            const int dy[4] = {0, 1, 0, -1};
            REP(r, 4){
                int nx[4], ny[4];
                memcpy(nx, x, sizeof(x));
                memcpy(ny, y, sizeof(y));
                bool ok = true;
                for(int i = 0; i < 4; i++) if(nx[i] == nx[0] && ny[i] == ny[0]){ // i = 0 -> true
                    nx[i] += dx[r];
                    ny[i] += dy[r];
                    if(!valid(nx[i], ny[i], W, H) || grid[ny[i]][nx[i]] == '#') ok = false;
                }
                for(int i = 0; i < 4; i++) for(int j = i + 1; j < 4; j++) if(nx[i] == nx[j] && ny[i] == ny[j]) ok = false;
                int ns = encode(nx, ny);
                if(ok && !dist.count(ns)){
                    que.push(ns);
                    dist[ns] = dist[s] + 1;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 60332
IDENTIFICATION DIVISION.
PROGRAM-ID. 135B.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP PIC X(150).
01 N   PIC 9(2).
01 I   PIC 9(2).
01 WR  PIC 9(2).
01 P   PIC 9(2).
01 P1  PIC 9(3).
01 P2  PIC 9(3).
*>
PROCEDURE DIVISION.
  ACCEPT N.
  ACCEPT INP.
*>
  MOVE 0 TO WR.
  MOVE 1 TO P1.
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > N
    PERFORM UNTIL INP(P1:1) NOT = ' '
      ADD 1 TO P1
    END-PERFORM
    PERFORM VARYING P2 FROM P1 BY 1 UNTIL INP(P2:1) = ' '
    END-PERFORM
*>
    MOVE INP(P1:P2 - P1) TO P
    IF (P NOT = I)
      ADD 1 TO WR
    END-IF
*>
    MOVE P2 TO P1
  END-PERFORM.
*>
  IF (WR <= 2)
    DISPLAY 'YES'
  ELSE 
    DISPLAY 'NO'
  END-IF.
*>
  STOP RUN.


Measured memory_bytes: 892
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define end(x) prev(x.end());
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define mset multiset
# define umap unordered_map
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
# define lr(i,l,r) for(int i=l;(l>r?i>=r:i<=r);(l>r?--i:++i))

using namespace std;

template<class T> void umin(T &a, T b) { a = min(a, b); }
template<class T> void umax(T &a, T b) { a = max(a, b); }

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

const int mod = 1e9+7;
const int N = 1e6+5;

int dp[N],a[105];

void solve(){
	ll n;
	cin>>n;
	map<ll,ll>m;
	pqueue<ll>q;
	ll ans=1;
	forn(i,n){
		ll x;
		cin>>x;
		m[x]++;
		if(m[x]==2 || m[x]==4){
			q.push(x);
		}
	}
	if(sz(q)>1){
		ans*=q.top();
		q.pop();
		ans*=q.top();
		cout<<ans;
	}
	else cout<<0;

}

int main(){
	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)
		solve();
	return 0;
}
 



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

int main() {
  ll n;
  cin >> n;
  ll ans = 1;
  ll aa[n];
  for (ll i = 0; i < n; i++) {
    cin >> aa[i];
  }
  sort(aa, aa + n);

  for (ll i = 0; i < n; i++) {
    __int128 d = (__int128)ans * (__int128)aa[i];
    if (d > (__int128)1e18) {
      cout << -1 << endl;
      return 0;
    }
    ans *= aa[i];
  }
  cout << ans << endl;
  return 0;
}

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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define EACH(begin, end) for(auto itr = (begin); itr != (end); itr++)

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;



ll N = 0;
ll M = 0;
ll ret = 0;
ll L, R;
ll l, r;

void input() {
  IN(N);
  IN(M);
  L = 1;
  R = N;
  REP(i, M) {
    IN(l);
    L = max(L, l);
    IN(r);
    R = min(R, r);
  }
  ret = max(0, (int)(R-L+1));
  PRINT(ret);
}

void solve() {

}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'

int main(int argc, char const *argv[]) {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    int n,r;
    cin>>n>>r;
    cout<<(n>=10?r:r+100*(10-n))<<endl;
}

Measured memory_bytes: 256
/*************************************************************************
	> File Name: 1.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com 
	> Blog: https://blog.csdn.net/Pig_cfbsl 
	> Created Time: 2020/5/30 20:00:18
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define LL long long
using namespace std;
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
char s[2000010];
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
	scanf("%s",s);
	int len=strlen(s);
	For(i,0,len-1)
		if(s[i]=='?') s[i]='D';
	printf("%s",s);
	return 0;
}


Measured memory_bytes: 3916
#include <iostream>
#include<iomanip>
using namespace std;
int main(){
    int a,b,d,r;
    double f;
    cin >> a >> b;
    d = a / b;
    r = a % b;
    f = 1.0 * a / b;
    cout << d <<" "<< r << " " << fixed << setprecision(20) << f << endl;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }

const int maxn = 1e6 + 7;

int main() {

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

    vector<vector<ll>> v;
    v.assign(2, vector<ll>(2));
    cin >> v[0][0] >> v[0][1];
    cin >> v[1][0] >> v[1][1];
    sort(v.begin(),v.end());

    vector<ll> pos;
    vector<ll> neg;
    int cntz = 0;
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            ll poss = v[0][i] * v[1][j];
            if (poss > 0) pos.push_back(poss);
            else if (poss < 0) neg.push_back(poss);
            else cntz++;
        }
    }

    if (pos.empty()) {
        if (cntz > 0) out(0);
        if ((v[0][0] <= 0 && 0 <= v[0][1]) || v[1][0] <= 0 && 0 <= v[1][1]) out(0);
        sort(neg.begin(),neg.end());
        out(neg.back());
    }

    assert(!pos.empty());
    sort(pos.begin(),pos.end());
    out(pos.back());
    
    
    return 0;
}


Measured memory_bytes: 3672
// GRL_1_A
#include <iostream>
#include <vector>
#include <queue>
#include <math.h>
#define   N   1000000000
using namespace std;

struct edge{
	int adj;
	int dis;
};

int main(){
	int V, E, r, s, t, d, x;
	vector<vector<edge> > A;
	vector<int> distance;
	queue<int> ver;
	edge e;

	cin>>V>>E>>r;

	A.resize(V);
	for(int i=0;i<V;i++){
		distance.push_back(N);
	}
	distance[r] = 0;

	for(int j=0;j<E;j++){
		cin>>s>>t>>d;
		e.adj = t;
		e.dis = d;
		A[s].push_back(e);
	}
	
	ver.push(r);
	while(!ver.empty()){
		x = ver.front();
		for(int i=0;i<A[x].size();i++){
			if(distance[A[x][i].adj] > distance[x] + A[x][i].dis){
				distance[A[x][i].adj] = distance[x] + A[x][i].dis;
				ver.push(A[x][i].adj);
			}
		}
		ver.pop();
	}
	
	for(int i=0;i<V;i++){
		if(distance[i] >= N)
			cout<<"INF"<<endl;
		else
			cout<<distance[i]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 10684
#include <iostream>
#define ll long long int
using namespace std;

int main()
{
     ll n ,t ;
     cin>>n>>t  ;
     ll arr[n];
     ll ans  = 0;
     ll v ;
     for( ll i =  0 ; i< n  ;++i)
      {
          cin>>arr[i] ;
      }
      for(ll j =  1; j< n  ;++j)
      {
          if(arr[j] >= arr[j-1] + t)
           {
               ans += t ;
           }
           else
           {
               ans += (arr[j] - arr[j-1]) ;
           }

      }
      cout<<ans + t ;
    return 0;
}

Measured memory_bytes: 1792
#import string,itertools,fractions,heapq,re,array,bisect
#from math import *
#from collections import Counter
from copy import deepcopy
def rl(s): return xrange(len(s))

def makeTable(init, *dims):
    if 0 == len(dims): return deepcopy(init)
    return [makeTable(init, *dims[1:]) for i in xrange(dims[0])]

INF = 2147483647


import sys
stdin = sys.stdin

W, H = map(int, stdin.readline().strip().split())
area = [stdin.readline().strip() for _ in range(W)]

rr = makeTable(1, W, H)
for x in range(W):
    rr[x][0] = 2
    if x % 2 == 1:
        for y in range(H-1):
            rr[x][y] = 2

for x in range(W):
    for y in range(H):
        if area[x][y] == '#':
            rr[x][y] = 3

for x in range(W):
    print ''.join(('#' if v & 1 else '.') for v in rr[x])

print ""

for x in range(W):
    print ''.join(('#' if v & 2 else '.') for v in rr[x])



Measured memory_bytes: 5628
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <climits>
#include <math.h>
#include <utility>
using namespace std;

typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

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

int main() {
	string a, b;
	cin >> a >> b;
	int n, m;
	n = a.size(); m = b.size();
	if (n > m) {
		cout << "GREATER" << endl;
		return 0;
	}
	else if (m > n) {
		cout << "LESS" << endl;
		return 0;
	}
	else {
		rep(i, n) {
			if (a.at(i) != b.at(i)) {
				if (a.at(i) > b.at(i)) {
					cout << "GREATER" << endl;
					return 0;
				}
				else {
					cout << "LESS" << endl;
					return 0;
				}
			}
		}
	}
	cout << "EQUAL" << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
cnt = 0
for i, v in enumerate(a):
    if v < 0:
        cnt += 1
    a[i] = abs(a[i])
a.sort()
if cnt % 2 == 0:
    print(sum(a))
else:
    print(sum(a) - a[0] * 2)


Measured memory_bytes: 14412
#include <bits/stdc++.h>  // ver1.9
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
#define PAI 3.14159265358979
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(14);
  int r=0,b=0,n;
  string s;
  cin >> n >> s;
  rep(i,0,n){
    if(s[i]=='R') r++;
    else b++;
  }
  if(r>b) cYes;
  else cNo;
  return 0;
}


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

const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.14159265;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,n,r) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()

#define cout cout << setprecision(12)

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template < typename T >
inline void dbg(T a) { cout << a << ' '; }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

int main() {
    cin >> n >> m;
    if (n > m) {
      REP(i,n) {
        cout << m;
      }
    }else {
        REP(i,m) {
          cout << n;
        }
      }
    }


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int A = in.nextInt();
            int B = in.nextInt();

            int count = 0;
            for (int i = A; i <= B; i++) {
                if (isPalindrome("" + i)) {
                    count++;
                }
            }
            System.out.println(count);
        }
    }

    private static boolean isPalindrome(String s) {
        for (int l = 0, r = s.length() - 1; l < r; l++, r--) {
            if (s.charAt(l) != s.charAt(r)) {
                return false;
            }
        }
        return true;
    }
}


Measured memory_bytes: 39096
#include<bits/stdc++.h>
using namespace std;
#define fr(x,i,n) for(int x = i; x < n; ++x)
#define fb(x,i,n) for(int x = i; x >= n; --x)
#define pr pair<int,int>
#define ll long long int
const int mod=1e9+7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s,t;
    cin>>s>>t;
    int x,y;
    cin>>x>>y;
    string u;
    cin>>u;
    if(u==s)
    x--;
    else
    y--;
    cout<<x<<" "<<y;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
//#define INF (1LL<<59)
 
int main(){
	int t;
	cin>>t;
	while(t--){
		vector<int> a(9);
		vector<char> c(9);
 
		rep(i,9)cin>>a[i];
		rep(i,9)cin>>c[i];
 
		int v[3][9]={};
		rep(i,9){
			if(c[i]=='R')v[0][a[i]-1]++;
			if(c[i]=='G')v[1][a[i]-1]++;
			if(c[i]=='B')v[2][a[i]-1]++;
		}
 
		int count=0;
		rep(i,3){
			rep(j,7){
				if(v[i][j]==0)continue;
				if(v[i][j] && v[i][j+1] && v[i][j+2] ){
					int r = min({v[i][j],v[i][j+1],v[i][j+2]});
					v[i][j]-=r,v[i][j+1]-=r,v[i][j+2]-=r;
					count+=r;
				}
			}
		}
		rep(i,3){
			rep(j,9){
				if(v[i][j]==0)continue;
				count+=v[i][j]/3;
				v[i][j] -= v[i][j]/3*3;
			}
		}
		if(count==3)cout<<1<<endl;
		else cout<<0<<endl;
	}
}

Measured memory_bytes: 3088
open Scanf
open Printf

let flip f x y = f y x

let read_int () = scanf " %d" (fun x -> x)
let rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)

let rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f

let () = let a = read_int () in printf "%d\n" (48 - a)



Measured memory_bytes: 384
import itertools
def solve():
    S = list(input())
    products = itertools.product(('+','-'),repeat=3)

    ans = ""
    for p in products:
        equation = ""
        for i in range(3):
            equation += S[i] + p[i]
        equation += S[3]

        if eval(equation) == 7:
            ans = equation
            break
    
    print(equation + "=7")

if __name__ == '__main__':
    solve()

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

ll dp[51][5001];//dp[i][j+2500]...i番目までの取った数字の和がjになるような組み合わせの数

int main()
{
	int n;
	ll a;
	ll x[51];
	ll ans=0;
	
	cin>>n>>a;
	for(int i=0;i<n;i++)
	{
		cin>>x[i+1];
		x[i+1]-=a;
	}
	
	//初期化
	fill(dp[0],dp[51],0);
	dp[0][2500]=1;
	//ここからdp
	for(int i=1;i<n+1;i++)
	{
		for(int j=0;j<5001;j++)
		{
			dp[i][j]=dp[i-1][j]; //上書き
		}
		for(int j=0;j<5001;j++)
		{
			if(j+x[i]>-1 && j+x[i]<5001)
				dp[i][j+x[i]]+=dp[i-1][j];
		}
	}
	ans=dp[n][2500]-1;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>

using namespace std;

int main()
{
    int n,i;
    int *p, *h;

    cin>>n;

    p=new int [n];
    h=new int [n];

    for(i=0; i<n; ++i) cin >> i[p];
    for(i=0; i<n; ++i) cin >> i[h];

    int *piyo,*hoge;

    piyo=new int [n];
    hoge=new int [n];

    0[piyo] = 0[p];
    (n-1)[hoge] = (n-1)[h];

    for(i=1; i<n; ++i){
        i[piyo] = (i-1)[piyo] + i[p];
        (n-i-1)[hoge] = (n-i)[hoge] + (n-i-1)[h];
    }

    int ans = 0;

    for(i=0; i<n; ++i){
        int a = i[piyo] + i[hoge];
        if(a>ans) ans = a;
    }

    cout << ans << endl;

    delete [] h;
    delete [] p;
    delete [] hoge;
    delete [] piyo;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	int a,b,s;
	char op;
	scanf("%d %c %d", &a, &op, &b);
	if(op=='+'){
         s= a+b;
	printf("%d",s);
}
	else if(op=='-'){
        s= a-b;
	printf("%d",s);
}
	
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    priority_queue<int> q;
    rep(i,n) {
        cin >> a[i];
        q.push(a[i]);
    }
    rep(i,n) {
        int t = q.top(); q.pop();
        if (t != a[i]) {
            cout << t << endl;
            q.push(t);
        }
        else {
            int u = q.top(); q.pop();
            cout << u << endl;
            q.push(t);
            q.push(u);
        }
    }
    
    return 0;
}

Measured memory_bytes: 5104
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,n,m) for(int i=n;i<int(m);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

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

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 ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=100010;

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



Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
	static void main() throws Exception{
		int n=sc.nextInt();
		int[]in=sc.intArr(n);
		int[]pref=new int[n],suf=new int[n];
		for(int i=0;i<n;i++) {
			pref[i]=in[i]^(i==0?0:pref[i-1]);
		}
		for(int i=n-1;i>=0;i--) {
			suf[i]=in[i]^(i==n-1?0:suf[i+1]);
		}
		for(int i=0;i<n;i++) {
			int ans=(i==0?0:pref[i-1])^(i==n-1?0:suf[i+1]);
			pw.print(ans+" ");
		}
	}
	public static void main(String[] args) throws Exception{
		pw=new PrintWriter(System.out);
		sc = new MScanner(System.in);
		int tc=1;
//		tc=sc.nextInt();
		while(tc-->0)
			main();
		pw.flush();
	}
	static PrintWriter pw;
	static MScanner  sc;
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void shuffle(int[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			int tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
	static void shuffle(long[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			long tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
}

Measured memory_bytes: 61068
#include <cstdio>

using namespace std;

double a[10];

int main()
{
    while( scanf( "%lf\n", &a[0] ) != EOF )
    {
        for( int i = 1; i < 10; i++ )
        {
            if( i % 2 )
            {
                a[i] = a[i - 1] * 2.0;
            }
            else
            {
                a[i] = a[i - 1] / 3.0;
            }
        }
        
        for( int i = 0; i < 10; i++ )
        {
            a[i] += ( i == 0 ? 0 : a[i - 1] );
        }
        printf( "%.8lf\n", a[9] );
    }
    return 0;
}


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

int main(){
	string s;
	cin >> s;
	
	int cnt=0;
	for(int i=0; i<s.size(); i++){
		if(i%2==0 && s[i]=='L') cnt++;
		else if(i%2==1 && s[i]=='R') cnt++;
		else cnt = cnt;
	}
	if(cnt==0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
s = input()

def has_A(x):
    if x[0] == 'A': return True
    return False


def has_C(x):
    if x[2:-1].count('C') == 1: return True
    return False


def is_lower_this_case(x):
    i = x.index('C')
    if x[1:i].islower() and x[i+1:].islower():
        return True
    return False

if has_A(s) and has_C(s) and is_lower_this_case(s):
    print('AC')
else:
    print('WA')

Measured memory_bytes: 9128
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int H;
    cin >> H;
    int dep = 0;
    while (H > 0) {
        H /= 2;
        dep++;
    }

    // 公比2、長さdep、初項1
    int ans = 1;
    for (int i = 0; i < dep; i++) ans *= 2;
    cout << ans - 1 << endl;

    return 0;
}

Measured memory_bytes: 764
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <climits>
#include <cmath>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll gcd(ll a, ll b){return b? gcd(b, a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  bool positive = false;
  string ans = "";
  if(N == 0){
    ans = "0";
  }else{
    while(N!=0){
      if(N%2!=0){
        N-=1;
        ans = "1" + ans;
      }else{
        ans = "0" + ans;
      }
      N = N/(-2);
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int x,n;cin>>x>>n;
  vector<int>p(n);
  rep(i,n)cin>>p[i];
  
  int mn=1000,ans;
  rep(i,102){
    if(count(all(p),i))continue;
    if(mn>abs(x-i)){
      mn=abs(x-i);
      ans=i;
    }
  }
  cout<<ans; 
}

Measured memory_bytes: 3632
from statistics import median
n = int(input())
a, b = [], []
for i in range(n):
    a_, b_ = map(int, input().split())
    a.append(a_)
    b.append(b_)
am, bm = median(a), median(b)
print(int(max(0, bm - am) * 2) + 1 if n % 2 == 0 else int(max(0, bm - am)) + 1)

Measured memory_bytes: 28784
import java.util.Scanner;


public class Main {

    public static String Y = "Yes";
    public static String N = "No";
    public static String I = "IMPOSSIBLE";
    public static String B = "Bad";
    public static String G = "Good";
    public static long MOD = (long) (Math.pow(10, 9) + 7);
    public static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {

        long a = nl();
        long b = nl();
        long c = nl();
        long k = nl();

        if (k <= a) {
            out(k);
        } else if (k <= a + b) {
            out(a);
        } else {
            out(a - (k - a - b));
        }
    }

    public static int count(String search, String text) {

        int nsearch = search.length();
        int ntext = text.length();
        int count = 0;

        for (int i = 0; i <= ntext - nsearch + 1; i++) {
            for (int j = i + nsearch - 1; j < ntext; j++) {
                if (search.equals(text.substring(i, j + 1))) {
                    count++;
                }
            }
        }

        return count;
    }

    /*
     * 以下メソッド集
     */
    static int ni() {

        return sc.nextInt();
    }

    static long nl() {

        return sc.nextLong();
    }

    static String n() {

        return sc.next();
    }

    static char[] nc() {

        return sc.next().toCharArray();
    }

    static int kaijo(int n) {

        if (n == 0 || n == 1) {
            return 1;
        } else {
            return n * kaijo(n - 1);
        }
    }

    static int fib(int n) {

        return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
    }

    static long lcm(long m, long n) {

        return m * n / gcd(m, n);
    }

    static int lcm(int m, int n) {

        return m * n / gcd(m, n);
    }

    static long gcd(long a, long b) {

        return (b == 0) ? a : gcd(b, a % b);
    }

    static int gcd(int a, int b) {

        return (b == 0) ? a : gcd(b, a % b);
    }

    static void out(String info) {

        System.out.println(info);
    }

    static void out(int info) {

        System.out.println(info);
    }

    static void out(double info) {

        System.out.println(info);
    }

    static void out(long info) {

        System.out.println(info);
    }

    static void out(char info) {

        System.out.println(info);
    }

    static void outn(String info) {

        System.out.print(info);
    }

    static void outn(int info) {

        System.out.print(info);
    }

    static void outn(double info) {

        System.out.print(info);
    }

    static void outn(long info) {

        System.out.print(info);
    }

    static void outn(char info) {

        System.out.print(info);
    }

    static int max(int a, int b) {

        return Math.max(a, b);
    }

    static long max(long a, long b) {

        return Math.max(a, b);
    }

    static int min(int a, int b) {

        return Math.min(a, b);
    }

    static long min(long a, long b) {

        return Math.min(a, b);
    }
}

Measured memory_bytes: 27104
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();
        if (A == 1) {
            A = 14;
        }
        if (B == 1) {
            B = 14;
        }
        if (A > B) {
            System.out.println("Alice");
        } else if (A < B) {
            System.out.println("Bob");
        } else {
            System.out.println("Draw");
        }
    }
}

Measured memory_bytes: 23764
using System;
class Program
{
    static void Main(string[] args)
    {
        string a = Console.ReadLine(); //標準入力
        string cha = a.Substring(a.Length-1, 1);
        if (cha == "s")
        {
            a = a + "es";
        }
        else
        {
            a = a + "s";
        }

        Console.WriteLine("{0}",a);
    }
    
}

Measured memory_bytes: 25956
N = int(input())
S = input()
al = [0 for _ in range(26)]
for i in range(N):
    al[ord(S[i])-97] += 1
count = 1
for j in range(26):
    count *= al[j]+1
    count %= 10**9+7
print((count-1)%(10**9+7))

Measured memory_bytes: 9296
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		double c = (double)a/b;
		String d = String.format("%.5f", c);
		System.out.println(a/b+" "+a%b+" "+d);
	}
}

Measured memory_bytes: 26232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int d[3]={a,b,c};
  sort(d,d+3);
  cout<<d[0]+d[1]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N; cin >> N;
  int sum=N;
  vector<int> MY(N);
  for (int i=0;i<N;i++){
    cin >> MY.at(i);
  }
  sort(MY.begin(), MY.end());
  for (int i=0;i<N-1;i++){
    if (MY.at(i) == MY.at(i+1)) sum--;
  }
  cout << sum << endl;
}

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

int main(){
    int n, a[105];
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    int time = 0, flag = 1;
    for(int i = 0; flag; i++){
        flag = 0;
        for(int j = 0; j < n - i - 1; j++){
            if(a[j] > a[j + 1]){
                swap(a[j], a[j + 1]);
                time ++;
                flag = 1;
            }
        }
    }
    for(int i = 0; i < n - 1; i++){
        printf("%d ", a[i]);
    }
    printf("%d\n", a[n - 1]);
    printf("%d\n", time);
    return 0;
}



Measured memory_bytes: 2696
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

int[][10000] T;
int[10000] MAX_ST;

void main()
{
    auto N = readln.chomp.to!int;
    foreach (_; 0..N-1) {
        auto ab = readln.split.to!(int[]);
        auto a = ab[0]-1;
        auto b = ab[1]-1;
        T[a] ~= b;
        T[b] ~= a;
    }
    auto CS = readln.split.to!(long[]);
    sort!"a > b"(CS);
    if (N == 1) {
        writeln(CS[0]);
        writeln(0);
        return;
    }
    long sum_c;
    foreach (c; CS[1..$]) sum_c += c;
    writeln(sum_c);

    int centroids;
    void find_centroids(int v, int parent) {
        MAX_ST[v] = 1;
        auto is_centroids = true;
        foreach (child; T[v]) {
            if (child == parent) continue;
            find_centroids(child, v);
            if (MAX_ST[child] > N / 2) is_centroids = false;
            MAX_ST[v] += MAX_ST[child];
        }
        if (N - MAX_ST[v] > N / 2) is_centroids = false;
        if (is_centroids) centroids = v;
    }
    find_centroids(0, -1);

    auto step = [centroids];
    MAX_ST[centroids] = -1;
    size_t i;
    long[] r;
    r.length = N;
    while (!step.empty) {
        int[] next_step;
        foreach (n; step) {
            r[n] = CS[i++];
            foreach (next; T[n]) {
                if (MAX_ST[next] < 0) continue;
                MAX_ST[next] = -1;
                next_step ~= next;
            }
        }
        step = next_step;
    }
    writeln(r.to!(string[]).join(" "));
}

Measured memory_bytes: 4092
h, n = [int(x) for x in input().split()]
listk = [int(x) for x in input().split()]
listk.sort()
if n <= h:
    for i in range(0,n):
        listk.pop()
else:
    for i in range(0,h):
        listk.pop()
print(sum(listk))

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

using namespace std;

int main(){
    int n,s1=0,s2=0,s3=0,s4=0,count=0;
    vector<vector<int>> data(3, vector<int>(3));

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> data[i][j];
        }
    }

    cin >> n;

    vector<int> b(n);

    for(int k=0;k<n;k++){
        cin >> b[k];
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                if(data[i][j] == b[k]) data[i][j] = 0;
            }
        }
    }

    for(int i=0;i<3;i++){
        s1 = data[i][0] + data[i][1] + data[i][2];
        s2 = data[0][i] + data[1][i] + data[2][i];
        if(s1==0 || s2==0){
            break;
        }
    }

    s3 = data[0][0] + data[1][1] + data[2][2];
    s4 = data[2][0] + data[1][1] + data[0][2];

    if(s1==0||s2==0||s3==0||s4==0) cout << "Yes" << endl;
    else cout << "No" <<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

long long a, b, c;
int x, y;
int main() {
    cin >> a >> b >> c >> x >> y;
    long long mincost = 1e12;
    int maxAB = max(x, y);
    for(int i = 0; i <= maxAB; ++i) {
        long long cost = c*i*2;
        int acnt = max(x-i, 0);
        int bcnt = max(y-i, 0);
        cost += (a*acnt + b*bcnt);
        chmin(mincost, cost);
    }
    cout << mincost << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int r = in.nextInt();
			out.println(3 * r * r);
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;	

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

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

		public char nextChar() {
			return next().charAt(0);
		}

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

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

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

	}
}


Measured memory_bytes: 21460
N = int(input())
pre = input()
dict = {pre:1}
for i in range(N-1):
    now = input()
    if now[0]!=pre[-1]:
        print('No')
        exit(0)
    elif now in dict:
        print('No')
        exit(0)
    else:
        dict[now] = 1
        pre = now 
print('Yes')

Measured memory_bytes: 9096
#include<stdio.h>
#include<math.h>
int main(void)
{
	int A,B;
	scanf("%d\n%d",&A,&B);
	if(A<=8)
	{
		if(B<=8)
		{
			printf("Yay!");
		}
		else
		{
			printf(":(");
		}
	}
	else
	{
		printf(":(");
	}
	return 0;
}

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

#define int long long
#define pb push_back
#define st first
#define nd second
#define sz(x) ((int)x.size())
#define ins insert
using namespace std;

const int maxn=3e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;

int gcd(int a,int b){
    return b==0?a:gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
int x[maxn]={};
int y[maxn]={};
main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m,k;
    cin>>n>>m>>k;
    set<int>mx;
    set<int>my;
    mx.ins(0);
    my.ins(0);
    map<pair<int,int>,int>mp;
    while(k--){
        int tx,ty;
        cin>>tx>>ty;
        int nx,ny;
        nx=x[*mx.begin()];
        ny=y[*my.begin()];
        x[tx]++;
        y[ty]++;
        mp[{tx,ty}]=1;
        if(x[tx]>=nx){
            if(x[tx]>nx)
                mx.clear();
            mx.ins(tx);
        }
        if(y[ty]>=ny){
            if(y[ty]>ny)
                my.clear();
            my.ins(ty);
        }
    }
    int f=0;
    for(auto i:mx){
        for(auto j:my){
            if(mp[{i,j}]==0){
                f=1;
                break;
            }
        }
        if(f)break;
    }
    if(f)cout<<x[*mx.begin()]+y[*my.begin()]<<endl;
    else cout<<x[*mx.begin()]+y[*my.begin()]-1<<endl;
}
/**
5 5
1 1
5 5
.#.#.
#####
.###.
#####
.#.#.
**/


Measured memory_bytes: 55140
S = input()
Q = int(input())


class Node:
    def __init__(self, value=None, prev=None, next=None):
        self.value = value
        self.prev = prev
        self.next = next

    def __str__(self):
        return str(self.value)


class LinkedList:
    def __init__(self, initial_string=None):
        self.first = Node()
        self.last = Node()
        self.first.next = self.last
        self.last.prev = self.first
        self.should_reverse = False
        for s in initial_string:
            self.insert_last(s)

    def _insert_first(self, value=None):
        prev_next = self.first.next
        self.first.next = Node(value, self.first, prev_next)
        prev_next.prev = self.first.next

    def _insert_last(self, value=None):
        prev_prev = self.last.prev
        self.last.prev = Node(value, prev_prev, self.last)
        prev_prev.next = self.last.prev

    def insert_first(self, value=None):
        if self.should_reverse:
            self._insert_last(value)
        else:
            self._insert_first(value)

    def insert_last(self, value=None):
        if self.should_reverse:
            self._insert_first(value)
        else:
            self._insert_last(value)

    def set_reverse(self):
        self.should_reverse = not self.should_reverse

    def _print(self):
        node = self.first.next
        while node is not None:
            if node.value is not None:
                print(node, end="")
            node = node.next
        print("")

    def _print_reverse(self):
        node = self.last.prev
        while node is not None:
            if node.value is not None:
                print(node, end="")
            node = node.prev
        print("")

    def print_list(self):
        if self.should_reverse:
            self._print_reverse()
        else:
            self._print()


def formation():
    global S, Q

    linked_list = LinkedList(S)

    for _ in range(Q):
        t_str = input()

        if t_str[0] == '1':
            linked_list.set_reverse()
        else:
            split = t_str.split(' ')
            f = split[1]
            c = split[2]
            if f == '1':
                linked_list.insert_first(c)
            else:
                linked_list.insert_last(c)

    linked_list.print_list()


formation()


Measured memory_bytes: 54652
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

void Sieve(bool is_prime[],int n){
	for(int i=0; i<n; ++i) is_prime[i]=true;
	is_prime[0]=is_prime[1]=false;
	for(int i=2; i*i<=n; ++i){
		if(is_prime[i]){
			for(int j=2*i; j<n; j+=i) is_prime[j]=false;
		}
	}
}

void Solve(){
	bool is_prime[200020];
	Sieve(is_prime,200000);
	vector<int> prime;
	REP(i,0,200000) if(is_prime[i]) prime.push_back(i);
	
	while(true){
		int m,a,b;
		cin >> m >> a >> b;
		if(m==0&&a==0&&b==0) break;

		int ansp=0,ansq;
		for(int i=m; i>=4; --i){
			if(ansp!=0) break;
			REP(j,0,prime.size()){
				if(i%prime[j]!=0) continue;
				int p=prime[j],q=i/prime[j];
				if(p*p>m) break;
				if(!is_prime[q]) continue;
				if((double)a/b<=(double)p/q&&(double)p/q<=1){
					ansp=p;
					ansq=q;
					break;
				}
			}
		}

		cout << ansp << ' ' << ansq << endl;
	}
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	Solve();
	return 0;
}

Measured memory_bytes: 1552