akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

int main() {
    long long A, B, C, D;
    while (cin >> A >> B >> C >> D) {
        long long t = (C + B - 1) / B;
        long long a = (A + D - 1) / D;
        if (t > a) cout << "No" << endl;
        else cout << "Yes" << endl; 
    }
}

















Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair
 
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
const int N = 55;

int n,m,q;
int a[N], b[N], c[N], d[N];

int x[N], ans;
void go(int from, int base) {
    if (from > n) {
        int sum = 0;
        forn(i,q) if (x[b[i]]-x[a[i]] == c[i]) sum += d[i];
        ans = max(ans, sum);
        return;
    }
    for (int i = base; i <= m; i++) {
        x[from] = i;
        go(from+1, i);
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m >> q;
    forn(i,q) cin >> a[i] >> b[i] >> c[i] >> d[i];
    go(1,1);
    cout << ans;
    return 0;
}


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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    ll A, B, K;
    cin >> A >> B >> K;
    if (A + B <= K) {
        print(0 << " " << 0);
    } else if (K <= A) {
        print(A - K << " " << B);
    } else if (K < A + B) {
        print(0 << " " << B - (K-A));
    }
}

signed main() {
    solve();
}


Measured memory_bytes: 256
#C問題  
N=int(input())
a=list(map(int,input().split()))
a.sort()
MINA=a[0]
MAXA=a[-1]
roop=MAXA-MINA
MIN=(a[-1]*N)**2
s=MINA
for i in range(roop+1):
    che=0
    for j in range(N):
        che+=(a[j]-s)**2
    MIN=min(MIN,che)
    s+=1
print(MIN)

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

int sum(int i) {
	return (1 + i)*i / 2;
}
int main() {
	int n;
	while (scanf("%d", &n), n) {
		int cnt = 0;
		for (int i = 0; i <= n; i++) {
			for (int j = i + 2; j <= n; j++) {
				if (sum(j) - sum(i) == n)cnt++;
			}
		}
		printf("%d\n", cnt);
	}
}

Measured memory_bytes: 3124
#include <stdio.h>

int Ssort(int *,int);

int main(){
  int A[100],N,i,count;
  scanf("%d",&N);
  for(i=0;i<N;i++) scanf("%d",&A[i]);
  count=Ssort(A,N);
  for(i=0;i<N;i++){
    if(i>0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n%d\n",count);
  return 0;
}

int Ssort(int *A,int N){
  int i,j,x,count=0,minj;
  for(i=0;i<N;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(A[j] < A[minj]) minj=j;
    }
    x=A[i];
    A[i]=A[minj];
    A[minj]=x;
    if(i!=minj)count++;
  }
  return count;
}



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

bool isPalin(string S)
{
    for (int i = 0; i < S.length(); i++) {
        if (S[i] != S[S.length()-i-1]) {
            return false;
        }
    }
    return true;
}


int main(void)
{
    string S;
    cin >> S;

    int N = S.length();
    
    bool strongPalindrome = true;

    // 1st condition
    if (!isPalin(S)) {
        cout << "No" << endl;
        return 0;
    }

    // 2nd condition
    if (!isPalin(S.substr(0, (N-1)/2))) {
        cout << "No" << endl;
        return 0;
    }

    // 3rd condition
    if (!isPalin(S.substr((N+3)/2-1))) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
}


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

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

  string s, t; cin >> s >> t;
  int cnt = 0;
  REP(i, SZ(s)) {
    cnt += s[i] != t[i];
  }
  cout << cnt << endl;

}








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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1e11;

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

  int mn = min(n, k);
  ll ans = -1LL * INF;

  for (int i = 0; i <= mn; ++i) {
    for (int j = 0; i + j <= mn; ++j) {
      vector<ll> a;
      int cnt = k - i - j;
      ll tans = 0;
      for (int l = 0; l < i; ++l) a.push_back(v[l]);
      for (int l = 0; l < j; ++l) a.push_back(v[n - 1 - l]);
      for (auto at : a) tans += at;
      sort(a.begin(), a.end());
      for (int l = 0; l < cnt && l < a.size() && a[l] < 0; ++l) tans -= a[l];
      ans = max(ans, tans);
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
using namespace std;
 
int main(){

    int N;
    long long  a[100010],max=0,second=0;

    cin >> N;

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

    sort(a,a+N,greater<int>());

    for(int i=0;i<N-1;i++){
        if(a[i]==a[i+1]){
            if(max==0){
                max=a[i];
                i+=1;
            }else if(second==0){
                second=a[i];
                break;
            }
        }
    }

    cout << max * second << endl;
}

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

#define ll long long int
ll mod=1e9+7;
const ll sz=1e6+100;
bool mark[sz];
vector<ll> prime;
ll tot[sz];
ll pos[sz];
ll siz;
ll table[80000][26];
vector<ll> bin;

void seive()
{
    ll n,m,i,j,k,sq;
    sq=sqrt(sz);
    prime.push_back(2);

    for(i=3;i<sz;i+=2) mark[i]=true;
    for(i=3;i<=sq;i+=2){
        if(mark[i]){
            for(j=i*i;j<sz;j+=i) mark[j]=false;
        }
    }

    for(i=3;i<sz;i+=2){
        if(mark[i]) prime.push_back(i);
    }
    siz=prime.size();

    for(i=0;i<siz;i++) pos[prime[i]]=i;
}

int main()
{
    seive();
    memset(mark,false,sizeof mark);
    ll i,j,k,p,x,q,y,n,m;
    cin>>n;
    ll ara[n];
    for(i=0;i<n;i++){
        cin>>x;
        ll sq=sqrt(x);
        ara[i]=x;

        for(j=0;j<siz && prime[j]<=sq;j++){
            ll ct=0;
            if(x % prime[j]==0){
                while(x % prime[j]==0) x/=prime[j], ++ct;
                tot[prime[j]]=max(tot[prime[j]], ct);
                sq=sqrt(x);
                if(mark[j]==false) bin.push_back(prime[j]), mark[j]=true;
            }
        }
        if(x>1){
            tot[x]=max(tot[x],1ll);
            if(mark[pos[x]]==false) mark[pos[x]]=true, bin.push_back(x);
        }
    }

    sort(bin.begin(),bin.end());
    ll b_siz=bin.size();

    for(i=0;i<b_siz;i++){
        pos[bin[i]]=i;
        table[i][0]=1;
        for(j=1;j<=25;j++) table[i][j]=(bin[i] * table[i][j-1])%mod;
    }

    ll ans=0;


    for(i=0;i<n;i++){
        ll x=ara[i];
        ll temp[b_siz];
        for(j=0;j<b_siz;j++) temp[j]=tot[bin[j]];

        ll sq=sqrt(x);
        for(j=0;j<b_siz && bin[j]<=sq;j++){
            if(x % bin[j]==0){
                while(x % bin[j]==0) x/=bin[j], --temp[j];
                sq=sqrt(x);
            }
        }

        if(x>1) --temp[pos[x]];

        ll sum=1ll;

        for(j=0;j<b_siz;j++) sum=(sum * table[pos[bin[j]]][temp[j]])%mod;
        ans=(ans + sum)%mod;
    }

    cout<<ans<<'\n';
}



Measured memory_bytes: 20340
import sys
inp = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

def resolve():
    N, Q = map(int, inp().split())

    AB = [[int(x) for x in inp().split()] for _ in range(N - 1)]
    PX = [[int(x) for x in inp().split()] for _ in range(Q)]

    graph = [[] for _ in range(N + 1)]
    for a, b in AB:
        graph[a].append(b)
        graph[b].append(a)

    value = [0] * (N + 1)
    for p, x in PX:
        value[p] += x

    def dfs(v, parent):
        for i in graph[v]:
            if i == parent:
                continue
            value[i] += value[v]
            dfs(i, v)

    dfs(1, 0)
    ans = ' '.join(map(str, value[1:]))
    return print(ans)

if __name__ == "__main__":
    resolve()

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A - B >= C) cout << 0 << endl;
    else cout << (C - (A - B)) << endl;
}


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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

template<typename T>
istream& operator>>(istream &is, vector<T> &v){
	for(int i=0; i<v.size(); i++) is >> v[i];
	return is;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(20) << fixed;

	int x; cin >> x;
	if(x>=30) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3540
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    T1,T2 = MI()
    A1,A2 = MI()
    B1,B2 = MI()
    if T1*A1+T2*A2==T1*B1+T2*B2:
        print("infinity")
        exit()
    A1*=T1
    B1*=T1
    A2*=T2
    B2*=T2
    diff1 = A1-B1
    diff2 = A2-B2
    # print(diff1,diff2)

    if diff1*diff2>0:
        print(0)
    else:
        if abs(diff1)>abs(diff2):
            print(0)
            exit()
        else:
            ans = 2 * (abs(diff1) // abs(diff1+diff2))
            if diff1//(diff1+diff2) == diff1/(diff1+diff2):
                ans -= 1 ##ピッタリ原点
            print(ans + 1)
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 64012
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(all(a));
    int ans = a[n/2] - a[(n-1)/2];
    cout << ans << '\n';
}

int main(void){ 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

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

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define l(i) (n / 2 - (n - i + 1) / 2)
#define r(i) ((i + 1) / 2)
#define st(i) (i / 2 - 1)
using namespace std;
typedef long long ll;
int n, a[200005];
ll dp[200005][3], ans = -1e16;  // j�ķ�Χ��i/2-1��(i+1)/2�����3��
int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++)
        for (int j = 0; j < 3; j++) dp[i][j] = -1e16;
    dp[1][1 - st(1)] = a[1], dp[1][0 - st(1)] = 0;
    for (int i = 2; i <= n; i++) {
        for (int j = l(i); j <= r(i); j++) {
            if (j == 0)
                dp[i][j - st(i)] = 0;
            else {
                for (int k = i - 2; l(k) <= j - 1 && r(k) >= j - 1 && k >= 0;
                     k--)
                    dp[i][j - st(i)] =
                        max(dp[i][j - st(i)], dp[k][j - 1 - st(k)] + a[i]);
            }
        }
    }
    for (int i = n / 2; i <= n; i++)
        for (int j = l(i); j <= r(i); j++)
            if (j == n / 2) ans = max(ans, dp[i][j - st(i)]);
    cout << ans;
    return 0;
}


Measured memory_bytes: 9108
/**
* C - Peaks
 * https://atcoder.jp/contests/abc166/tasks/abc166_c
 */
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    // AtCoder丘陵には N 個の展望台があり、展望台 i の標高は Hi です。
    int N, M;
    cin >> N >> M;

    vector<int> H(N);
    map<int, bool> mp;
    for (int i = 0; i < N; i++) {
        cin >> H.at(i);
        mp[i] = true;
    }

    // また、異なる展望台どうしを結ぶ M 本の道があり、道 j は展望台 Aj と展望台 Bj を結んでいます。
    for (int i = 0; i < M; i++) {
        int A, B;
        cin >> A >> B;
        if (H.at(A - 1) > H.at(B - 1)) {
            mp.erase(B - 1);
        } else if (H.at(A - 1) == H.at(B - 1)) {
            mp.erase(B - 1);
            mp.erase(A - 1);
        } else {
            mp.erase(A - 1);
        }
    }

    // 良い展望台がいくつあるか求めてください。
    cout << mp.size() << endl;
}
 

Measured memory_bytes: 8316
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
    int n;
    cin >> n;
    bool ans=false;
    REP(i, 9)if(n % i == 0 && 0 < n/i && n/i < 10)ans=true;
    if(ans)cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;

int func(int num){
  if(num%2==0)return num/2;
  else return 3*num+1;
}

int main(){
  int n;cin>>n;
  int ans=2, pre=n;
  map<int, int> check;
  while(true){
    check[pre]=true;
    if(check[func(pre)]){
      break;
    }
    pre=func(pre);
    ans++;
  }
  cout << ans << endl;
}


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

string s;
vector<int> v;

signed main() {
	cin >> s;
	int cnt1 = 0;
	int cnt0 = 0;
	for (size_t i = 0; i < s.size(); i++)
	{
		if (s[i] == '1') {
			cnt1++;
		}
		else {
			cnt0++;
		}
	}
	int ans = min(cnt0, cnt1) * 2;

	cout << ans << endl;
}




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

int main()
{
	int N, ans = 1, max = 0, s = 0;

	cin >> N;

	for (int i = 1, j = 0; i <= N; i++) {
		j = i;
		s = 0;
		for (;;) {
			if (j % 2)break;
			j /= 2;
			s++;
			if (max < s) {
				max = s;
				ans = i;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np


def main():
    h, w, d = [int(x) for x in input().split()]
    dic = {}
    for i in range(h):
        line = [int(x) for x in input().split()]
        for j, a in enumerate(line):
            dic[a] = (a, i, j)
    magic = [[0] for _ in range(d + 1)]
    for k in range(1, d + 1):
        for m in range(1, h * w):
            if k + (m * d) > h * w:
                break
            magic[k].append(magic[k][m - 1] +
                            abs(dic[k + (m * d)][1] - dic[k + ((m - 1) * d)][1]) +
                            abs(dic[k + (m * d)][2] - dic[k + ((m - 1) * d)][2]))
    q = int(input())
    for _ in range(q):
        l, r = [int(e) for e in input().split()]
        k = d if l % d == 0 else l % d
        print(magic[k][(r - 1) // d] - magic[k][(l - 1) // d])


main()


Measured memory_bytes: 37172
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int list1[50]{};
    int N;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>list1[i];
    }
    int c{};
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            c+=list1[i]*list1[j];
        }
    }
    for(int i=0;i<N;i++){
        c-=list1[i]*list1[i];
    }
    cout<<c/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < s.length(); i++){
        if (s[i] == t[i]) ans ++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;
//abc166a

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s;
    cin>>s;
    if(s=="ABC") cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
(全探索できるなら全探索しろ)
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'\n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え(=でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
*/

Measured memory_bytes: 3612
package main

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

func solve() {
	h := getInt()
	ans := 0
	for i := 0; h > 0; i++ {
		h /= 2
		ans += (1 << i)
	}

	fmt.Fprintln(wr, ans)
}

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

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


Measured memory_bytes: 1776
def gcd(n,m)
  while m%n!=0 do
    t = n
    n = m%n
    m = t
  end
  return n
end

mod = 1000000007

N = gets.to_i
A = gets.split.map(&:to_i)

lcd=1
N.times do |i|
  lcd = lcd*A[i]/gcd(lcd,A[i])
end

ans=0
N.times do |i|
  ans += lcd / A[i]
end

puts ans % mod

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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;
typedef std::tuple<int, int, int> tiii;

const double PI = 3.1415926535897932;
const int INF = (int)1e9;
const ll LINF = 1e18;
const ll MOD = 1000000007;
const int dr[4] = {1, 0, -1, 0};
const int dc[4] = {0, 1, 0, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T, typename U, typename V> inline
ostream& operator<<(ostream &o, tuple<T,U,V> &p)
{
    return o << "{" << get<0>(p) << "," << get<1>(p) << "," << get<2>(p) << "}";
}

template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &v)
{
    int len = v.size();
    for(int i = 0; i < len; i++) { 
        os << v[i];
        if(i != len-1) { os << ","; } 
    } 
    return os;
}

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

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

int main(void)
{
    int h, w, n;
    cin >> h >> w >> n;

    v_int a(h*w);
    int idx = 0;
    
    irep(i, n) {
        int cnt;
        cin >> cnt;
        irep(j, cnt) {
            a[idx++] = i+1;
        }
    }
    
    irep(i, h) {
        irep(j, w) {
            if(i % 2) {
                cout << a[i*w+j] << " ";
            } else {
                cout << a[(i+1)*w-1-j] << " ";
            }
        } cout << endl;
    }
    return 0;
}

/*atcoder*/


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

using namespace std;

int main()
{
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[0]==5 && a[1]==5 && a[2]==7) cout<<"YES";
    else cout<<"NO";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
char s[100005];
int win=0,los=0,len,maxn=1000000,pa,ro;
void dfs(int k)
{
//	for(int j=1;j<=2;j++){
//		
//	}
	
	if(s[k]=='g'){
		if(pa+1<=ro){
			win++;
			pa++;
			dfs(k+1);
			pa--;
			win--;
//			cout<<
	//		if(los+1<=win){
	//			los++;
	
	//			dfs(k+1);
				
	//			los--;
	//		}
			
			
			
		}
		else{
	//		los++;
				ro++;
				dfs(k+1);
				ro--;
	//		los--;
			}
		
	}
	if(s[k]=='p'){
		if(pa+1<=ro){
		
//		if(los<=win+1){
			pa++;
			dfs(k+1);
			pa--;
//		}
//		win++;
//			dfs(k+1);
//		win--;
		}
		else{
			los++;
			ro++;
			dfs(k+1);
			ro--;
			los--;
		}
	}
	if(k==len&&pa<=ro){
		if(maxn>(win-los))maxn=(win-los);
//		cout<<win-los<<" ";
	}
	
}
int  main(){
	scanf("%s",&s);
len=strlen(s);
//	cout<<len;
	dfs(0);
//	for(int i=0;i<len;i++){
//		if(s[i]=='g'&&los<=win)win++;
//		else los++;
//		if(s[i]=='p'&&los<=win)los++;
//		else win++;
//	}
//	cout<<win-los;ggppgggpgg
cout<<maxn;
}


Measured memory_bytes: 3456
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include <algorithm>
#include <string>

using namespace std;

#define U unsigned
#define S short
#define L long
#define LL long long 
#define LLU long long unsigned

//Reading and Printing Arrays

//short int
#define rhd(arr, n) for(int aab = 0; aab < n; aab++){scanf("%hd", &arr[aab]);}
#define phd(arr, n) for(int aab = 0; aab < n; aab++){printf("%hd ", arr[aab]);}
//int
#define rd(arr, n) for(int aab = 0; aab < n; aab++){scanf("%d", &arr[aab]);}
#define pd(arr, n) for(int aab = 0; aab < n; aab++){printf("%d ", arr[aab]);}
//unsigned int
#define ru(arr, n) for(int aab = 0; aab < n; aab++){scanf("%u", &arr[aab]);}
#define pu(arr, n) for(int aab = 0; aab < n; aab++){printf("%u ", arr[aab]);}
//long int
#define rld(arr, n) for(int aab = 0; aab < n; aab++){scanf("%ld", &arr[aab]);}
#define pld(arr, n) for(int aab = 0; aab < n; aab++){printf("%ld ", arr[aab]);}
//unsigned long int
#define rlu(arr, n) for(int aab = 0; aab < n; aab++){scanf("%lu", &arr[aab]);}
#define plu(arr, n) for(int aab = 0; aab < n; aab++){printf("%lu ", arr[aab]);}
//long long int
#define rlld(arr, n) for(int aab = 0; aab < n; aab++){scanf("%lld", &arr[aab]);}
#define plld(arr, n) for(int aab = 0; aab < n; aab++){printf("%lld ", arr[aab]);}
//unsigned long long int
#define rllu(arr, n) for(int aab = 0; aab < n; aab++){scanf("%llu", &arr[aab]);}
#define pllu(arr, n) for(int aab = 0; aab < n; aab++){printf("%llu ", arr[aab]);}
//float
#define rf(arr, n) for(int aab = 0; aab < n; aab++){scanf("%f", &arr[aab]);}
#define pf(arr, n) for(int aab = 0; aab < n; aab++){printf("%f ", arr[aab]);}
//double
#define rlf(arr, n) for(int aab = 0; aab < n; aab++){scanf("%lf", &arr[aab]);}
#define plf(arr, n) for(int aab = 0; aab < n; aab++){printf("%lf ", arr[aab]);}
//char
#define rc(arr, n) for(int aab = 0; aab < n; aab++){scanf("%c", &arr[aab]);}
#define pc(arr, n) for(int aab = 0; aab < n; aab++){printf("%c", arr[aab]);}
//string
#define rs(arr) scanf("%s", arr);
#define ps(arr) puts(arr);

//swap
#define swap(a, b, tip) tip tempswap = a;a = b;b = tempswap;
//freopen
#define freopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);

/*       ▄▀▄     ▄▀▄
        ▄█░░▀▀▀▀▀░░█▄
    ▄▄  █░░░░░░░░░░░█  ▄▄
   █▄▄█ █░░▀░░┬░░▀░░█ █▄▄█       */

int min(int a, int b){	return a <= b ? a : b;}
int max(int a, int b){	return a >= b ? a : b;}
int findmin(int arr[], int n){int min = 0;for(int i = 1; i < n;min = arr[i] < arr[min] ? i : min, i++);return min;}
int findmax(int arr[], int n){int max = 0;for(int i = 1; i < n;max = arr[i] > arr[max] ? i : max, i++);return max;}
int arrsum(int arr[], int n){int sum = 0;for(int i = 0; i < n; sum += arr[i], i++);return sum;}
	
int main(){

	int a, b;

	scanf("%d %d", &a, &b);

	printf("%d", (a * (a - 1) / 2) + (b * (b - 1) / 2));
}

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

#define ll long long
#define debug(x) cerr << fixed << #x << " is " << x << endl;

const int MAX_N = 100005;

int dp[MAX_N];
bool ok = 1;
int n, m;

vector<pair<int, int>> adj[MAX_N];
vector<int> adj_inv[MAX_N];
vector<int> top_order;

void topologicalSort()
{
	vector<int> degree(n, 0);
	for(int i = 0; i < n; i++)
		for(auto j : adj[i])
			degree[j.first]++;

	queue<int> q;
	for(int i = 0; i < n; i++)
		if(degree[i] == 0)
			q.push(i);

	int cnt = 0;

	while (!q.empty())
	{
		int u = q.front();
		q.pop();
		top_order.push_back(u);

		for(auto i : adj[u])
			if (--degree[i.first] == 0)
				q.push(i.first);
		cnt++;
	}

	//cicle found
	if (cnt != n)
		ok = 0;
}

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

	cin >> n >> m;
	if(m < 2)
	{
		cout << "Yes" << endl;
		return 0;
	}

	map<pair<int, int>, int> dt;
	while(m--)
	{
		int l, r, d;
		cin >> l >> r >> d;
		l--, r--;
		// if(dt.find({l, r}) != dt.end())
		// {
		// 	if(d == 0 && dt[{l, r}] != 0)
		// 		ok = 0;
		// 	if(d != 0)
		// 		ok = 0;
		// }
		dt[{l, r}] = d;
		adj[l].push_back({r, d});
		adj_inv[r].push_back(l);
	}

	topologicalSort();
	dp[0] = 0;
	for (int i = 1; i < (int)top_order.size() && ok; i++)
	{
		set<int> poss;
		for(auto j : adj_inv[top_order[i]])
			poss.insert(dp[j] + dt[{j, top_order[i]}]);
		if(poss.size() > 1)
			ok = 0;
		if(poss.size() != 0)
			dp[top_order[i]] = *poss.begin();
	}

	cout << (ok ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 25204
A, B, C, D = map(int, input().split())

takahashi_turn = True
while A > 0 and C > 0:
    if takahashi_turn:
        C = C - B
    else:
        A = A - D
    takahashi_turn = not takahashi_turn

if A > 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9172
#それゆけにぶたんまん
#python3.8.2のTLEの壁に阻まれました←ぱいぱいまんに助けてもらった
#てかライブラリ使えばよくねver
from bisect import bisect_left
n = int(input())
l = sorted(list(map(int,input().split())))

ans = 0
for i in range(n):
    for j in range(i+1,n):
        k = bisect_left(l,l[i]+l[j])
        ans += k-1 - j

print(ans)


Measured memory_bytes: 9320
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <ctime>

#define inf 0x3f3f3f3f
#define Inf 0x3FFFFFFFFFFFFFFFLL
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Rep(i, n) for (int i = 1; i <= (n); ++i)
#define clr(x, a) memset(x, (a), sizeof x)
using namespace std;
typedef long long ll;
int a[111];
int s[111], c[111];
int main() {
  clr(a, 0xff);
  int n, m; cin >> n >> m;
  bool f = 0;
  rep(i, m) {
    cin >> s[i] >> c[i];
    if (a[s[i]] != -1 && a[s[i]] != c[i]) f = 1;
    else a[s[i]] = c[i];
  }
  if (f) cout << "-1" << endl;
  else if (n > 1 && a[1] == 0) cout << "-1" << endl;
  else {
    Rep(i, n) {
      if (a[i] == -1) {
        if (i == 1 && n > 1) a[i] = 1;
        else a[i] = 0;
      }
      cout << a[i];
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>

#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vec vector<int>
#define vecll vector<ll>
#define pb(x) push_back(x)

using namespace std;
///////////////////////////////////////////////////////////



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

    vec x;
    int a;
    rep(i, n) {
        cin >> a;
        x.pb(a);
    }

    int mean = round((double)accumulate(x.begin(), x.end(), 0) / n);
    int ans = 0;
    rep(i, n)
        ans += pow(x[i] - mean, 2);
    cout << ans << endl;





    return 0;
}

Measured memory_bytes: 384
N = int(input())
L = list(map(int,input().split()))
if N <= 2:
    print(0)
else:
    ans = 0
    L.sort()
    for i in range(N):
        for j in range(i,N):
            for k in range(j,N):
                if L[i]+L[j] > L[k] and L[i]<L[j]<L[k]:
                    ans += 1
    print(ans)

Measured memory_bytes: 73568
#include <bits/stdc++.h>
#include <iomanip>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PLDLD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VB;
 
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
#define endl "\n"
 
const LD eps=1e-10;
const long long INFLL=(LL)(1e9)*(LL)(1e9);
const int INF=1e9;
 
template<class T>
void chmin(T& a, const T b)
{
	if(a>b)
		a=b;
}
template<class T>
void chmax(T& a, const T b)
{
	if(a<b)
		a=b;
}
 
const LL pow(const LL p, const LL q)
{
	LL t=1;
	for(int i=0;i<q;i++)
		t*=p;
	return t;
}

template <typename T>
struct has_iter
{
	private:
		template <typename U>
		static constexpr true_type check(typename U::iterator*);
		template <typename U>
		static constexpr false_type check(...);

	public:
		static constexpr bool value = decltype(check<T>(nullptr))::value;
};


template<typename T, typename U = typename T::iterator>
void print(const T& container)
{
		auto&& first=begin(container), last=end(container);
		auto&& back=prev(last);
		for(auto e=first; e!=last; e=next(e))
			cout<<*e<<" \n"[e==back];
}


extern void* enabler;
template<typename Head, typename enable_if<!has_iter<Head>::value>::type*& = enabler>
void print(const Head& head)
{
	cout<<head<<endl;
}

template<> void print<string>(const string& container)
{
	cout<<container<<endl;
}

template<typename Head, typename... Tail>
void print(const Head& head, const Tail&... tail)
{
	cout<<head<<" ";
	print(tail...);
}

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

template<typename T>
istream& operator >> (istream& is, vector<T>& vec)
{
	for(T& x: vec) is >> x;
	return is;
}


template<typename T, typename U>
ostream& operator << (ostream& os, const pair<T, U>& p)
{
	os<<'('<<p.first<<", "<<p.second<<')';
	return os;
}

template<typename T>
vector<T> read(int n)
{
	vector<T> t(n);
	cin>>t;
	return t;
}

template<typename T>
T read()
{
	T t;
	cin>>t;
	return t;
}

template<typename Head, typename... Tail>
struct vector_demensions
{
	using type=vector<typename vector_demensions<Tail...>::type>;
};

template<typename Head>
struct vector_demensions<Head> { using type=Head; };

template<typename T>
vector<T> make_vectors(int size, T val)
{
	return vector<T>(size, val);
}

template<typename T=int, typename... Args>
auto make_vectors(int size, Args... tail)
	-> typename vector_demensions<Args..., T>::type
{
	auto val=make_vectors<T>(forward<Args>(tail)...);
	return vector<decltype(val)>(size, val);
}


int main()
{
	int a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;
	if(x<y)
	{
		swap(x,y);
		swap(a,b);
	}
	int ans=2*c*x;
	chmin(ans, a*x+b*y);
	chmin(ans, a*(x-y)+2*c*y);
	print(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]!='h' || s[i+1]!='i'){
			cout<<"No"<<endl;
			return(0);
		}
		i+=1;

	}
	cout<<"Yes"<<endl;
  return(0);
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void) {
	int N, M;
	cin >> N >> M;
	int NN = 0;
	int MM = 0;
	for (int i = 0; i < N; i++) {
		NN += i;
	}
	for (int i = 0; i < M; i++) {
		MM += i;
	}

	int Ans = NN + MM;

		cout << Ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    int H = Integer.parseInt(S[0]);
    int W = Integer.parseInt(S[1]);
    
    char[][] field = new char[H][W];
    int white = 0;
    Queue<Integer> qx = new ArrayDeque<>();
    Queue<Integer> qy = new ArrayDeque<>();
    for(int i = 0; i < H; i++){
      String T = sc.nextLine();
      for(int j = 0; j < W; j++){
        field[i][j] = T.charAt(j);
        if(field[i][j] == '.'){
          white++;
        }else{
          qx.add(i);
          qy.add(j);
        }
      }
    }
    
    int[] sx = {0,0,1,-1};
    int[] sy = {1,-1,0,0};
    int ans = 0;
    
    while(white > 0){
      int count = 0;
      int n = qx.size();
      for(int i = 0; i < n; i++){
        int a = qx.poll();
        int b = qy.poll();
        for(int j = 0; j < 4; j++){
          int A = a+sx[j];
          int B = b+sy[j];
          if(A >= 0 && A < H && B >= 0 && B < W){
            if(field[A][B] == '.'){
              field[A][B] = '#';
              qx.add(A);
              qy.add(B);
              count++;
            }
          }
        }
      }
      ans++;
      white -= count;
    }
    System.out.println(ans);
  }
}

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

int main(){
  int n; cin>>n;
  vector<pair<ll,ll>> z;
  vector<pair<ll,ll>> xy(n);
  for(int i=0; i<n; ++i)cin>>xy[i].first>>xy[i].second;

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

  for(int i=0; i<n-1; ++i){
    for(int j=i+1; j<n; ++j){
      z.push_back(make_pair(xy[j].first-xy[i].first, xy[j].second-xy[i].second));
    }
  }

  sort(z.begin(), z.end());
  int lm=1, l=1;
  for(int i=1; i<z.size(); ++i){
    if(z[i-1]==z[i])++l;
    else{lm=max(lm, l); l=1;}
  }
  lm=max(lm,l);

  if(n==1)cout<<1<<endl;
  else cout<<n-lm<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
ll n;
//ld ;
//string s;

int main() {
    cin >> n;
    ll x[n];
    for(ll i=0;i<n;i++){
        cin >> x[i];
    }
    ll mini = 10000000;
    if(n>1){
        for(ll j=1;j<=100;j++){
           ll temp = 0;
          for(ll k=0; k<n; k++){
              temp += ((j-x[k])*(j-x[k]));
         }
          mini = min(mini,temp);
        }
    }else{
        mini = 0;
    }
    cout << mini << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ul unsigned long long int
#define vi vector<int>
#define vl vector<int64_t>
#define all(x) x.begin(),x.end()
#define pb push_back
#define fo(x,a,b) for(int x=a; x<b; x++)
#define rfo(x,a,b) for(int x=a; x>=b; x--)
#define fi first
#define sec second
#define mp make_pair
int sgn(int x) { return x>0 ? 1 : ( x<0 ? -1 : 0); }
typedef pair<int,int> pairs;
double pi = 3.14159265358979323846;
ll mod = 1000000007;

void solve()
{
    ll h,w,m;
    cin>>h>>w>>m;
    vi a(h,0),b(w,0),c,d;
    set<pairs> s;
    fo(i,0,m)
    {
        int x,y;
        cin>>x>>y;
        x--; y--;
        s.insert(mp(x,y));
        a[x]++;
        b[y]++;
    }
    int ma=0,maa=0;
    fo(i,0,h)
    {
        if(a[i]>ma) { c.clear(); c.pb(i); ma=a[i]; }
        else if(a[i]==ma) c.pb(i);
    }
    fo(i,0,w)
    {
        if(b[i]>maa) { d.clear(); d.pb(i); maa=b[i]; }
        else if(b[i]==maa) d.pb(i);
    }
    bool good = false;
    fo(i,0,c.size())
    {
        fo(j,0,d.size())
        {
            if(s.find(mp(c[i],d[j]))==s.end()) {good = true; break; }
        }
        if(good) break;
    }
    if(good) cout<<ma+maa;
    else cout<<ma+maa-1;
    cout<<"\n";
    return;
}
int main()
{
#ifdef _DEBUG
    freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll t;
    //cin>>t;
    //while(t--)
    {
        solve();
    }
    return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2>

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

signed main() {
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cout << fixed << setprecision(12);

    int n;
    cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];
    int m;
    cin >> m;
    vint b(m);
    rep(i, m) cin >> b[i];
    vint res;
    set_union(all(a), all(b), inserter(res, res.end()));
    for (int x : res) cout << x << endl;

    return 0;
}


Measured memory_bytes: 10204
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

class question {
public:
	int N;
	vector<int> X;
	
	void ans() {
		cin >> N;
		X.resize(N);
		REP(i, N) cin >> X[i];
		vector<int> x = X;
		sort(x.begin(), x.end());
		int m[2] = { x[N / 2 - 1],x[N / 2] };
		REP(i, N) {
			int res = m[0];
			if (X[i] <= res) res = m[1];
			cout << res << "\n";
		}
	}
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	question q;
	q.ans();
	
	return 0;
}


Measured memory_bytes: 3840
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;
 
 
public class Main {
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc = new Scanner(System.in);
	
		long r = Long.parseLong(sc.next());
		long D = Long.parseLong(sc.next());
		long x = Long.parseLong(sc.next());
		for(int i=0;i<10;i++){
			x = r*x-D;
			System.out.println(x);
			
		}
		
		
		
	}
	
	
	
}

Measured memory_bytes: 21076
import java.util.Scanner;

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

        String result ;
        if(R < 1200 ){
            result = "ABC";
        }else if(R < 2800 ){
            result = "ARC";
        }else {
            result = "AGC";
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		double t = sc.nextDouble() + 0.5;
		int sum = 0;
		double time = t / a;

		for (int i = 1; i < time; i++) {
			sum += b;
		}

		System.out.println(sum);

		sc.close();

	}
}


Measured memory_bytes: 37016
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=3e3+10;
const int M=1e5+10;
const int mod=1e9+7;
int n,m,t,fac[M<<1],inv[M<<1],dp[N];
struct node{
	int r,c;
	node(int rr=0,int cc=0){r=rr;c=cc;}
	bool operator <(const node&e)const{return c<e.c||(c==e.c&&r<e.r);}//woc你怎么又忘了元素相等时要特殊判断啊！ 
}w[N];
inline void Add(int &x,int y){x+=y;x-=x>=mod? mod:0;}
inline void Preprocess(){
	fac[0]=1;for(register int i=1;i<=n+m;i++)fac[i]=1ll*fac[i-1]*i%mod;
	inv[0]=inv[1]=1;for(register int i=2;i<=n+m;i++)inv[i]=(-1ll*mod/i*inv[mod%i]%mod+mod)%mod;
	for(register int i=2;i<=n+m;i++)inv[i]=1ll*inv[i-1]*inv[i]%mod;
}
inline int C(int n,int m){if(n<0||m<0||n<m)return 0;return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;}
int main(){
	scanf("%d%d%d",&n,&m,&t);
	for(register int i=1;i<=t;i++)
		scanf("%d%d",&w[i].r,&w[i].c);
	sort(w+1,w+t+1);w[++t]=node(n,m);Preprocess();
	for(register int i=1;i<=t;i++){
		dp[i]=C(w[i].r+w[i].c-2,w[i].r-1);
		for(register int j=1;j<i;j++)
			if(w[j].r<=w[i].r)Add(dp[i],mod-1ll*dp[j]*C(w[i].r-w[j].r+w[i].c-w[j].c,w[i].r-w[j].r)%mod);
	}
	printf("%d\n",dp[t]);
	return 0;
}

Measured memory_bytes: 1792
n,a,b = map(int, input().split())
s = input()
cnt = 0
x = 0
for i in range(n):
    if s[i] == "a":
        if cnt < a+b: 
            cnt += 1
            print("Yes")
        else: print("No")
    elif s[i] == "b":
        if cnt < a+b and x+1 <= b:
            cnt += 1
            x += 1
            print("Yes")
        else: print("No")
    else: print("No")

Measured memory_bytes: 9288
n = int(input())
a = list(map(int,input().split()))

s = 1
if n == 0:
    if a[0] != 1:
        print(-1)
        quit()
    else:
        print(1)
        quit()
elif a[0] > 0:
    print(-1)
    quit()
memo = [[0,0] for _ in range(n+1)]
memo[0] = [0,1]
for i in range(1,n+1):
    if s == 0:
        print(-1)
        quit()
    s = memo[i-1][1]*2
    if s > 10**15:
        s = 10**15
    memo[i][0] = a[i]
    memo[i][1] = s-a[i]
    if s-a[i] < 0:
        print(-1)
        quit()
ans = [[a[i],0] for i in range(n+1)]
for i in range(n-1,-1,-1):
    if (ans[i+1][0]+ans[i+1][1]) > memo[i][1]*2:
        print(-1)
        quit()
    else:
        ans[i][1] = min(memo[i][1],ans[i+1][0]+ans[i+1][1])
s = 0
for i in range(n+1):
    s += sum(ans[i])
print(s)

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

int main(){
    int n,ans=0;
    cin>>n;

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

    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            ans=ans+d[i]*d[j];
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i < (n);i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define SCANF(i) int i;scanf("%d",&i)
typedef long long ll;
using namespace std;
using P = pair<int,int>;
const long long INF = 1LL << 60;
const int IINF=100000000;
const int MOD = (int)1e9 + 7;
//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    //sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
vector<int> dx={1,0,-1,0};vector<int> dy={0,-1,0,1};

signed main () {
    int h,w,k;cin >> h >> w >> k;
    vector<vector<char>> inlist(h,vector<char>(w));
    REP(i,h){
        string tmp;cin >> tmp;
        REP(j,w){
            inlist[i][j]=tmp[j];
        }
    }
    int ans=0;
    for(int hb=0;hb<(1<<h);hb++){
        for(int wb=0;wb<(1<<w);wb++){
            vector<vector<char>> tmplist=inlist;
            for(int i=0;i<h;i++){
                if(hb & (1<<i)){
                    REP(j,w){
                        tmplist[i][j]='a';
                    }
                }
            }
            for(int j=0;j<w;j++){
                if(wb & (1<<j)){
                    REP(i,h){
                        tmplist[i][j]='a';
                    }
                }
            }
            int tmpcnt=0;
            REP(i,h)REP(j,w){
                if(tmplist[i][j]=='#')tmpcnt++;
            }
            if(tmpcnt==k)ans++;
        }
    }
    cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  int sum = 0;
    
  for (int i = 0; i < N; i++){
    int l, r;
    cin >> l >> r;
    sum += r-l+1;    
  }
  cout << sum <<endl;
}

Measured memory_bytes: 256
def operation(ary, prev = [], i = 0)
  return i - 1, ary if ary == prev
  count = Hash.new(0)
  ary.each {|x| count[x] += 1}
  operation(ary.map {|x| count[x]}, ary, i + 1)
end

until $<.gets.to_i.zero?
  i, ary = operation($<.gets.split.map(&:to_i))
  puts i, ary.join(" ")
end


Measured memory_bytes: 6992
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int A, B;
    cin >> A >> B;
    cout << A*B - (A*1 + B*1 - 1) << endl;
    return 0;
}

Measured memory_bytes: 256