akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>

using namespace std;

#define REP(i, x) for(int i=0;i<(int)(x);i++)
#define REPS(i, x) for(int i=1;i<=(int)(x);i++)
#define RREP(i, x) for(int i=(int)(x)-1;i>=0;i--)
#define RREPS(i, x) for(int i=(int)(x);i>0;i--)
#define FOR(it, x) for(auto it=x.begin();it!=x.end();++it)
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
int d[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
template<class T>
ostream &operator<<(ostream &os, const vector<T> &v){
        os << "[";
        FOR(it, v) os << *it << ", ";
        return os << "]";
}

int n;
int g[30], x[30], y[30], r[30], c[30];
int ans;

int norm(int x, int y){
        return x*x+y*y;
}

int main(){
        while(cin >> n, n){
                REP(i, n){
                        cin >> x[i] >> y[i] >> r[i] >> c[i];
                }
                memset(g, 0, sizeof(g));
                vector<pii> p;
                REP(i, n)REP(j, i){
                        if(norm(x[i]-x[j], y[i]-y[j]) < (r[i]+r[j])*(r[i]+r[j])) g[i] |= 1 << j;
                        if(c[i] == c[j]) p.eb(j, i);
                }
                vector<unsigned char> dp(1<<n);
                dp[0] = 1;
                int ans = 0;
                REP(i, 1<<n)if(dp[i]){
                        FOR(it, p){
                                int j = it->first, k = it->second;
                                if((1&(i>>j)) || (1&(i>>k)) || (g[j]&~i) || (g[k]&~i)) continue;
                                dp[i|(1<<j)|(1<<k)] = 1;
                        }
                        ans = max(ans, __builtin_popcount(i));
                }
                cout << ans << endl;
        }
        return 0;
}

Measured memory_bytes: 17596
s = input()
sLen = len(s)
K = int(input())

result = set()
for i in range(sLen):
    for j in range(1, K + 1):
        if i + j > sLen:
            break
        ss = s[i:i+j]
        result.add(ss)
print(sorted(result)[K - 1])

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

#define f(i,n) for(int i = 0; i < n; i++)
#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define inf INT_MAX
#define pb push_back
#define all(x) x.begin(),x.end()
#define debug(x) cout<<" [ " << #x << " is: " << x << " ] "<<endl;
#define fast ios_base::sync_with_stdio(0); cin.tie(0);

#define mem(x,i) memset(x,i,sizeof x)


using namespace std;

int main () {
	
	fast;

	ll x;
	cin>>x;

	ll happiness=0;
	happiness+=(x/500)*1000;

	// happiness+=5*(happiness)
	happiness+=   5*((x- ((x/500)*500))/5);

	cout<<happiness<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

const int putterns[8][8]={
	{1,2,1,2,1,4,1,4},
	{1,2,1,4,1,4,1,2},
	{1,4,1,2,1,2,1,4},
	{1,4,1,4,1,2,1,2},
	{2,1,2,1,4,1,4,1},
	{2,1,4,1,4,1,2,1},
	{4,1,2,1,2,1,4,1},
	{4,1,4,1,2,1,2,1}
};

int main(void) {
	int kyaku[8];
	int now,min,mini;
	int i,j;
	while(scanf("%d%d%d%d%d%d%d%d",
			&kyaku[0],&kyaku[1],&kyaku[2],&kyaku[3],
			&kyaku[4],&kyaku[5],&kyaku[6],&kyaku[7])==8) {
		min=0x7fffffff;
		mini=0;
		for(i=0;i<8;i++) {
			now=0;
			for(j=0;j<8;j++) {
				if(kyaku[j]>putterns[i][j]) {
					now+=kyaku[j]-putterns[i][j];
				}
			}
			if(now<min) {
				min=now;
				mini=i;
			}
		}
		printf("%d %d %d %d %d %d %d %d\n",
			putterns[mini][0],putterns[mini][1],
			putterns[mini][2],putterns[mini][3],
			putterns[mini][4],putterns[mini][5],
			putterns[mini][6],putterns[mini][7]);
	}
	return 0;
}

Measured memory_bytes: 0
import sys
input = sys.stdin.readline
 
MAX = pow(10,6)
#L = get_sieve_of_eratosthenes(MAX)
 
def factorization(n):
    arr = []
    temp = n
    if temp%2 == 0:
      cnt = 0
      while temp%2 == 0:
        cnt += 1
        temp//=2
      arr.append(2)
    for i in range(3, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(i)
 
    if temp!=1:
        arr.append(temp)
 
    return arr
 
#XX = factorization(121)
#print(XX)
import math
N = int(input())
A = list(map(int,input().split()))
GCD = math.gcd(A[0],A[1])
for i in range(2,N):
  GCD = math.gcd(GCD,A[i])
  if GCD == 1:
    break
if GCD != 1:
  print("not coprime")
  exit()
A.sort()
SET = set([])
for x in A:
  SL = factorization(x)
  for yakusu in SL:
    if yakusu not in SET:
      SET.add(yakusu)
    else:
      print("setwise coprime")
      exit()
print("pairwise coprime")

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

using namespace std;

int bubbleSort(vector<int> &x, int n){
    int cnt = 0;
    bool flag = true;
    while(flag){
        flag = false;
        for(int j = n-1; 0 < j; j--){
            if(x[j] < x[j-1]){
                swap(x[j], x[j-1]);
                flag = true;
                cnt++;
            }
        }
    }
    return cnt;
}

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

    int ans = bubbleSort(A, N);
    for(int i = 0; i < N; i++) cout << A[i] << (i < N-1 ? " " : "");
    cout << "\n";
    cout << ans << "\n";
    
    return 0;
}


Measured memory_bytes: 3084
#include<stdio.h>

int main(void) {
   char s[3];
   scanf("%s",s);
   int cnt1 = 0;
   int cnt2 = 0;

   for(int i = 0; i < 3; i++) {
      if(s[i] == 'A') {
         cnt1++;
      }
      if(s[i] == 'B') {
         cnt2++;
      }
   }
   if(cnt1 > 0 && cnt2 > 0) {
      printf("Yes");
   } else {
      printf("No");
   }

   return 0;
}


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

int main(){
  int a,b;
  while(cin>>a>>b){
    int c=a+b;
    if(c==0)c=1;
    int i;
    for(i=0;c>0;i++){
      c/=10;
}
    cout<<i<<endl;
  }
}



Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <cstdint>

int main()
{
	std::vector<std::uint16_t> cars;
	std::uint16_t num;
	while (std::cin >> num) {
		if (num == 0) {
			std::cout << cars.back() << std::endl;
			cars.pop_back();
		}
		else {
			cars.push_back(num);
		}
	}
	return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, K;
  cin >> N >> K;
  vll a(N);
  REP(i, N){
    cin >> a[i];
  }

  //vvll dp(N, vll(K+1, 0));
  vvll dp(2, vll(K+1, 0));

  REP(j, a[0]+1){
    dp[0][j] = 1;
  }
  FOR(i, 1, N){
    ll tmp=0;
    REP(j, K+1){
      /*
      tmp += dp[i-1][j]%MOD;
      dp[i][j] = tmp%MOD;
      if(j>=a[i]) tmp -= dp[i-1][j-a[i]];
      while(tmp<0) tmp+=MOD;
      */
      tmp += dp[0][j]%MOD;
      dp[1][j] = tmp%MOD;
      if(j>=a[i]) tmp -= dp[0][j-a[i]];
      while(tmp<0) tmp+=MOD;
      /*
      for(int k=0; k<a[i]+1 && j-k>=0; ++k){
        dp[i][j] += dp[i-1][j-k];
      }
      */
    }
    swap(dp[0], dp[1]);
  }

  //mat_print(dp);

  //cout << dp[N-1][K]%MOD << "\n";
  cout << dp[0][K]%MOD << "\n";

  return 0;
}


Measured memory_bytes: 2688
#include "bits/stdc++.h"
#define REP(i, m, n) for(long long i = m; i < n; ++i)
#define CO(n) cout << n << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int N,M;
P ab[100010];

int main()
{
    ios::sync_with_stdio(false);
    cin >> N >> M;
    REP(i,0,M) cin >> ab[i].second >> ab[i].first;
    // cout << endl;
    sort(ab,ab+M);
    // REP(i,0,M) cout << ab[i].first << ' ' << ab[i].second << endl;
    int ans = 0; int t = 0;
    REP(i,0,M){
        if (t <= ab[i].second){
            t = ab[i].first;
            // CO(t);
            ++ans;
        }
    }
    CO(ans);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define gc getchar
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define be begin()
#define en end()
#define le length()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (__typeof(n) i = 0; i < n; i++)
#define repo(i, n) for (__typeof(n) i = 1; i <= n; i++)
#define fastIO                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define eps 1e-6
#define pi 3.141592653589793
#define c(a) cout << a << "\n";
#define ao(a)        \
    for (auto i : a) \
        cout << i << " ";
#define lc 2 * x // if tree index id 0 based
#define lr 2 * x + 1
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int N = 1e6 + 6;
/*

bool comp(string a, string b)
{
    return a.size() < b.size();
}
*/

ll a[10005], tree[100005], ans[10005];
void build(ll l, ll r, ll x)
{
    if (l == r)
        tree[x] = a[l];
    else
    {
        ll mid = (l + r) >> 1;
        build(l, mid, lc);
        build(mid + 1, r, lr);
        tree[x] = tree[lc] & tree[lr];
    }
}
ll query(ll lx, ll ly, ll l, ll r, ll x)
{
    if (l > r || lx > r || ly < l)
        return 1122343442;
    if (lx <= l && r <= ly)
        return tree[x];
    ll mid = (l + r) >> 1;
    ll ans;
    ans = query(lx, ly, l, mid, lc);
    ans &= query(lx, ly, mid + 1, r, lr);
    return ans;
}
int main()
{
  ll n;
  cin>>n;
  ll a[n];
  rep(i,n) cin>>a[i];
  ll sum=0;
  for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++) sum+=a[i]*a[j];
  }
  c(sum)

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const int mod=998244353;
int a[1000010];
int main()
{
	int n;
	cin >>n;
	cin >>a[0];
	int cot=0;
	int maxx=-1;
	for(int i=1;i<n;i++)
	{
		cin >>a[i];
		if(a[i]<=a[i-1]) cot++;
		else
		{
			maxx=max(maxx,cot);
			cot=0;
		}
	}
	maxx=max(maxx,cot);
	cout <<maxx<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int n; cin >> n;
  vector<int> abc(3),l(n);
  for(int i = 0; i < 3; i++) cin >> abc[i];
  for(int i = 0; i < n; i++) cin >> l[i];

  int ans = 1LL << 60;
  for(int i = 0; i < 1 << n; i++){
    for(int j = 0; j < 1 << n; j++){
      for(int k = 0; k < 1 << n; k++){
        if((i & j) || (j & k) || (k & i)) continue;
        vector<int> v(3,0);
        int res = 0;
        for(int bit = 0; bit < n; bit++){
          if(i >> bit & 1){
            v[0] += l[bit];
            res += 10;
          }
          if(j >> bit & 1){
            v[1] += l[bit];
            res += 10;
          }
          if(k >> bit & 1){
            v[2] += l[bit];
            res += 10;
          }
        }
        res = max(0LL, res - 30);
        for(int bit = 0; bit < 3; bit++){
          res += abs(abc[bit] - v[bit]);
          if(v[bit] == 0) res += 1LL << 60;
        }
        ans = min(ans, res);
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	int N;
	cin >> N;
	vector<vector<pair<int, int>>> v(N);
	for(int i = 0; i < N; i++) {
		int A;
		cin >> A;
		for(int j = 0; j < A; j++) {
			int x, y;
			cin >> x >> y;
			x--;
			v[i].push_back({x, y});
		}
	}
	int ans = 0;
	for(int bit = 0; bit < (1 << N); ++bit) {
		bool honest[N];
		int cnt = 0;
		for(int i = 0; i < N; i++) honest[i] = false;
		for(int i = 0; i < N; ++i)
			if(bit & (1 << i)) {
				honest[i] = true;
				cnt++;
			}

		bool ok = true;
		for(int i = 0; i < N; i++) {
			if(honest[i]) {
				for(int j = 0; j < v[i].size(); j++) {
					if(honest[v[i][j].first] && v[i][j].second == 0) ok = false;
					if(!honest[v[i][j].first] && v[i][j].second == 1) ok = false;
				}
			}
		}
		if(ok) ans = max(ans, cnt);
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 256
n = int(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数
m = [int(i) for i in input().split()] # 配列で数字

ans = 1
MAX = m[0]
for i in range(1, n):
    if m[i] >= MAX:
        ans += 1
    MAX = max(MAX, m[i])
print(ans)

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <cctype>
#include <fstream>

using namespace std;

#define ll long long
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define du(x) cout<<#x<<'='<<x<<endl
#define du2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define du3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddarr(arr,a,b) rep(i,a){rep(j,b){cout<<*(arr+i*b+j)<<' ';}cout<<endl;}
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf());


int main() {

    int A, B;
    cin >> A >> B;

    cout << ((A*B) % 2 != 0 ? "Yes" : "No")<<endl;


}

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


long mod = 1000000007;

//aのp乗を求めるアルゴリズム
//p=62の時、pの変化は、62->31->30->15->14->7->6->3->2->1->0
//と、半分半分になっていく
//よって、計算量はO(logp)になる
long modpow(long a, int p) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		//pが偶数の時
		int halfP = p / 2;
		long half = modpow(a, halfP);
		//a^(p/2) をhalfとして、half*halfを計算
		return half * half % mod;
	}
	else {
		//pが奇数の時は、
		//pを偶数にするために1減らす
		return a * modpow(a, p - 1) % mod;
	}
}


//(10*9*8)/(3*2*1);
//10*9*8 -> ansMul
//3*2*1 -> ansDiv
long calcComb(int a, int b) {
	if (b > a - b) return calcComb(a, a - b);


	long ansMul = 1;
	long ansDiv = 1;
	for (int i = 0; i < b; i++)
	{
		ansMul *= (a - i);
		ansDiv *= (i + 1);
		ansMul %= mod;
		ansDiv %= mod;
	}
	//ansMul / ansDivをやりたい
	//ansDivの逆元を使って求めよう！

	long ans = ansMul * modpow(ansDiv, mod - 2) % mod;
	return ans;
}


int main() {
	int N, M;
	cin >> N >> M;

	int MNokori = M;
	long ans = 1;
	// for (int i = 2; i * i <= MNokori; i++)
	int i = 2;
	while(MNokori!=1)
	{
		if (MNokori % i == 0) {
			int cnt = 0;
			while (MNokori % i == 0) {
				cnt++; MNokori /= i;
			}
			//cntが2^Xとか3^XのXの部分
			ans *= calcComb(N + cnt - 1, N - 1); //N-1はcntと同じ
			ans %= mod;
		}
		i++;
	}
	// if (MNokori != 1) {
	// 	//最後に素数が残ってる分を処理する
	// 	cout << MNokori << endl;
	// 	ans *= calcComb(N + 1 - 1, N - 1); //N-1はcntと同じ
	// 	ans %= mod;
	// }

	cout << ans << endl;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;  
cin >> N; 
int A[1010] = {}; 
long long int B[1010] = {}; 
for(int i = 1; i <= N; i++) {
A[i] = i; 
B[i] = 1; 
}
for (int j = 2; j <= N; j++) {
  for (int i = 1; i <= N; i++) {
    while(A[i] % j == 0){
B[j] ++; 
A[i] /= j; 
}
}
}
long long int ans = 1; 
long long int P = 1e9 + 7; 
for(int i = 1; i <= N; i++) {
ans = (ans * B[i]) % P; 
}
cout << ans << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
using namespace std;
#define MOD 1000000007




int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (b / a > c) {
		cout << c;
	}
	else {
		cout << b / a;
	}

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

struct intree{
  int key;
};

int size;
struct intree list[500001];
int Parent(int i){
   return i/2;
}

int Left(int i){
  return 2*i;
 }

int Right(int i){
  return 2*i+1;  
 }

void maxHeapify(int i){
  int left,right,largest;
 struct intree key;
  
left=Left(i);
  right=Right(i);

  if(left<=size && list[left].key>list[i].key)
    largest=left;
  else largest=i;
 
 if(right<=size && list[right].key>list[largest].key)
    largest=right;
 
 if(largest!=i){
    key=list[i];
    list[i]=list[largest];
    list[largest]=key;
    maxHeapify(largest);
  }  
}
void buildMaxHeap(){
  int i;
  for(i=(size/2);i>=1;i--) maxHeapify(i);
}





int main(void){
  int i,j;
  
  scanf("%d",&size);
  for(i=1;i<=size;i++) scanf("%d",&list[i].key);
 
  buildMaxHeap();
  
  for(i=1;i<=size;i++) printf(" %d",list[i].key);
  printf("\n");
  return 0;
}

Measured memory_bytes: 2552
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static String str = "";
	public static void main(String[] args) {
		while(read()){
			solve();
		}
	}
	
	static boolean read(){
		if( !sc.hasNext() )return false;
		for(int i = 0; i < 3; i++){
			int b = sc.nextInt();
			str += Integer.toString(b);
		}
		return true;
	}
	
	static void solve(){
		if( str.equals("100") || str.equals("010") || str.equals("000") ){
			System.out.println("Close");
		}else{
			System.out.println("Open");
		}
		str = "";
	}

}

Measured memory_bytes: 17316
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define repext(i, a, b) for (int i = a; i < b; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define repextrev(i, a, b) for (int i = b - 1; i >= a; i--)
#define vec_all(vec) vec.begin(), vec.end()

// vectorデバッグ
template <typename T>
void dump_vec(vector<T> vec)
{
    rep(i, vec.size())
    {
        cout << vec[i] << endl;
    }
}

template <typename T>
T gcd(T a, T b)
{
    if (a < b)
    {
        swap(a, b);
    }

    while (b != 0)
    {
        a = a % b;
        swap(a, b);
    }

    return a;
}

template <typename T>
T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}

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

    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }

    vector<int> l(n);
    vector<int> r(n);

    rep(i, n) {
        if (i == 0) {
            l[i] = a[i];
        } else {
            l[i] = gcd(l[i - 1], a[i]);
        }
    }

    reprev(i, n) {
        if (i == n - 1) {
            r[i] = a[i];
        } else {
            r[i] = gcd(r[i + 1], a[i]);
        }
    }

    int max = 0;
    int tmp_max = 0;
    rep(i, n) {
        if (i == 0) {
            tmp_max = r[i + 1];
        } else if (i == n - 1) {
            tmp_max = l[i - 1];
        } else {
            tmp_max = gcd(l[i - 1], r[i + 1]);
        }

        if (max < tmp_max) {
            max = tmp_max;
        }
    }

    cout << max << endl;
    
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  vector<vector<ll>> num(N, vector<ll>(26));
  rep(i, N) {
    cin >> s[i];
    sort(all(s[i]));
  }
  sort(all(s));
  ll ans = 0;

  ll seq = 1;
  repp(i, 1, N - 1) {
    if (s[i] == s[i - 1])
      seq++;
    else {
      ans += seq * (seq - 1) / 2;
      seq = 1;
    }
  }
  ans += seq * (seq - 1) / 2;

  cout << ans << endl;
}

Measured memory_bytes: 31488
#include<map>
#include<cstdio>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
map<pii,int> mp;
long long cnt[10],h,w,n;
int max(int x,int y)
{
 return (x>=y)? x:y;
}
int min(int x,int y)
{
  return (x<y)? x:y;
}
inline int read(){
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
int main()
{   
	h=read(),w=read(),n=read();
    int i,j;
while(n--)
{
  int x=read(),y=read();
  for (i=max(1,x-2);i<=min(h-2,x);++i)
  {
    for (j=max(1,y-2);j<=min(w-2,y);++j)
	{
      mp[pii(i,j)]++; 
    }
    }
  }
for (map<pii,int>::iterator iter=mp.begin();iter!=mp.end();iter++) cnt[iter->second]++,n++;
ll ans=1ll*(h-2)*(w-2);
 printf("%lld\n",ans-n-1);
for (i=1;i<=9;++i) printf("%lld\n",cnt[i]);
}

Measured memory_bytes: 42496
#include <bits/stdc++.h>
using namespace std;
int n,t,x,mi,ma,s;
int main(){
	scanf("%d%d",&n,&t);
	scanf("%d",&x);
	mi = x;
	ma = 0;
	s = 0;
	for (int i = 2; i <= n; i++){
		scanf("%d",&x);
		if (x > mi) {
			if (x - mi == ma) s++;
			if (x - mi > ma){
				ma = x - mi;
				s = 1;
			}
		} else
		mi = x;
	}
	printf("%d",s);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int temp[13] = { 0 };
int c[13];
int a[13][13];
int n, m, x;
bool flag = false;
int ans = 2e9;
bool check()
{
	for (int i = 1; i <= m; i++)
	{
		if (temp[i] < x)
			return false;
	}
	return true;
}
void dfs(int startx, int choose, int sum, int have)
{
	if (have == choose)
	{
		if (check())
		{
			ans = min(ans, sum);
		}
		return;
	}
	for (int i = startx; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			temp[j] += a[i][j];
		}
		dfs(i + 1, choose, sum + c[i], have + 1);
		for (int j = 1; j <= m; j++)
		{
			temp[j] -= a[i][j];
		}
	}
}
int main()
{
	cin >> n >> m >> x;
	for (int i = 1; i <= n; i++)
	{
		cin >> c[i];
		for (int j = 1; j <= m; j++)
		{
			cin >> a[i][j];
		}
	}
	for (int i = 1; i <= n; i++)
	{
		dfs(1, i, 0, 0);
	}
	if (ans == 2e9)
		cout << -1 << endl;
	else
		cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>

using namespace std;

int main() {
  int n,m;
  string s[200],t[200];
  cin >> n;
  for(int i = 0; i < n; i++)
    cin >> s[i];
  cin >> m;
  for(int i = 0; i < m; i++)
    cin >> t[i];

  int sum = 0;
  for(int i = 0; i < n; i++) {
    int cnt = 1;
    for(int j = i+1; j < n; j++)
      if(s[i] == s[j]) cnt++;
    for(int j = 0; j < m; j++)
      if(s[i] == t[j]) cnt--;
    sum = max(sum, cnt);
  }

  cout << sum << endl;
}

Measured memory_bytes: 3596
n,k=map(int,input().split())
s=input()
t = 0
tc = s[0]
s0 = s[0]
l=[]
if s0 == "0":
    l.append(0)
for c in s:
    if c ==tc:
        t+= 1
    else:
        l.append(t)
        t = 1
        tc = c
l.append(t)
if tc == "0":
    l.append(0)
res = 0
if len(l) < 2*k+1:
    print(sum(l))
else:
    suml = [0]
    for i in range(len(l)):
        suml.append(suml[i]+l[i])
    for i in range(0,len(suml)-(2*k+1),2):
        res = max(res,suml[2*k+1+i]-suml[i])
    print(res)

Measured memory_bytes: 7932
n, a, b = map(int, input().split())
total = 0

def sum_digits(digits):
  return sum(int(digit) for digit in str(digits))
  
for i in range(1, n+1):
  total_digits = sum_digits(i)
  if total_digits >= a and total_digits <= b:
    total += i
  
print(total)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=1e5+5,Mod=1e9+7;
char buf[1<<12],*p1=buf,*p2=buf,nc;int ny;
inline char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}char s[MAXN];int n,nxt[2][MAXN],F[MAXN],Sum,flg;
int main(){
	scanf("%s",s+1),n=strlen(s+1),flg=1;
	Rep(i,1,n)if(s[i]==s[i+1])flg=0;if(flg){puts("1");return 0;}
	F[n+1]=1,nxt[0][n+1]=nxt[1][n+1]=nxt[0][n+2]=nxt[1][n+2]=n+2;
	Red(i,n,1){
		(Sum+=(s[i]-'a'+1))%=3;
		nxt[0][i]=s[i]=='a'?i+1:s[i+1]=='b'?i+2:nxt[0][i+2];
		nxt[1][i]=s[i]=='b'?i+1:s[i+1]=='a'?i+2:nxt[1][i+2];
		F[i]=(F[nxt[0][i]]+F[nxt[1][i]]+(Sum==0))%Mod;
	}cout<<(F[1]-(Sum==0))<<'\n';
	return 0;
}




Measured memory_bytes: 4976
use std::io::{ stdin, stdout, BufRead, Write };

const SP   : u8 = b' ';
const LF   : u8 = b'\n';
const ZERO : u8 = b'0';

#[inline(always)]
fn uitoa(mut n: usize, buf: &mut Vec<u8>) {
  buf.clear();
  if n == 0 {
    buf.push(ZERO);
    return;
  }

  while n > 0 {
    buf.push((n % 10) as u8 + ZERO);
    n /= 10;
  }

  buf.reverse();
}

#[inline(always)]
fn atoui(s: &[u8]) -> usize {
  let mut n = 0;
  for b in &s[..] { n = n * 10 + (b - ZERO) as usize; }
  n
}

fn main() {
  let stdin = stdin();
  let mut stdin = stdin.lock();

  let mut buf = Vec::with_capacity(500 * 2);
  let len = stdin.read_until(SP, &mut buf).unwrap();
  buf.truncate(len - 1);
  let h = atoui(&buf);

  buf.clear();
  let len = stdin.read_until(LF, &mut buf).unwrap();
  buf.truncate(len - 1);
  let w = atoui(&buf);

  let mut num = Vec::with_capacity(3);
  let mut ans = Vec::new();
  let mut n   = 0;

  let mut odd = 0;
  let mut x   = 0;
  let mut y   = 0;

  for i in 0..h {
    buf.clear();
    stdin.read_until(LF, &mut buf).unwrap();

    if i % 2 == 0 {
      for j in 0..w {
        if odd != 0 {
          uitoa(y + 1, &mut num);
          num.push(SP);
          ans.write(&num).unwrap();

          uitoa(x + 1, &mut num);
          num.push(SP);
          ans.write(&num).unwrap();

          uitoa(i + 1, &mut num);
          num.push(SP);
          ans.write(&num).unwrap();

          uitoa(j + 1, &mut num);
          num.push(LF);
          ans.write(&num).unwrap();

          n += 1;
        }
        odd ^= buf[j * 2] & 1;
        y = i;
        x = j;
      }
    } else {
      for mut j in 0..w {
        j = w - 1 - j;

        if odd != 0 {
          uitoa(y + 1, &mut num);
          num.push(SP);
          ans.write(&num).unwrap();

          uitoa(x + 1, &mut num);
          num.push(SP);
          ans.write(&num).unwrap();

          uitoa(i + 1, &mut num);
          num.push(SP);
          ans.write(&num).unwrap();

          uitoa(j + 1, &mut num);
          num.push(LF);
          ans.write(&num).unwrap();

          n += 1;
        }
        odd ^= buf[j * 2] & 1;
        y = i;
        x = j;
      }
    }
  }

  let stdout = stdout();
  let mut stdout = stdout.lock();

  uitoa(n, &mut buf);
  buf.push(LF);
  stdout.write(&buf).unwrap();

  stdout.write(&ans).unwrap();
  stdout.flush().unwrap();
}


Measured memory_bytes: 8188
from collections import deque
n = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

#print(A)

wait = deque()
wait.append(A[0])
ans = 0
for a in A[1:]:
    #print(wait)
    ans += wait.popleft()
    wait.extend([a, a])
print(ans)


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

#define all(x) (x).begin(),(x).end()

#define MOD 1000000007

using namespace std;

int main(){
	int n;
	string s,t;
	cin >> n >> s >> t;

	for( int i=0; i<n; i++ )	cout << s[i] << t[i];
	cout << endl;

	return 0;
}


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

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

const int MOD = 1e9 + 7;
vector<vector<int> > edge;
long long dp[100006];
long long ans[100006];
int n, m;

void dfs(int node, int parent) {

    long long cur = 1;
    long long ss  = 1;

    for(auto ch: edge[node]) {
        if(ch != parent) {
            dfs(ch, node);
            cur += cur*dp[ch];
            cur %= m;
        }
    }
    dp[node] = cur ;
}

void dfs2(int node, int parent, long long value) {

    // cout << node << " " << parent << " -- ";

    long long cur = 1;

    vector<int> childs;

    long long total = 0;

    for(auto ch: edge[node]) {
        if(ch == parent) continue;
        childs.push_back(ch);
    }

    total = dp[node] + dp[node] * value;

    total %= m;
    if(childs.size() == 0) {
        ans[node] = total;
        return;
    }



    long long curdp[childs.size() + 1];
    long long rightdp[childs.size() ];
    curdp[0] = value + 1;

    for(int j = 0; j < childs.size(); ++j) {
        curdp[j+1] = curdp[j] + curdp[j] * dp[childs[j]];
        curdp[j+1] %= m;
    }
    rightdp[childs.size()-1] = dp[childs[childs.size()-1]] + 1;

    for(int j = childs.size()-2; j >= 0; --j) {
        rightdp[j] = rightdp[j+1] + rightdp[j+1] * dp[childs[j]];
        rightdp[j] %= m;
    }

    for(int i = 0; i < childs.size(); ++i) {
        cur = curdp[i] * dp[childs[i]];
        cur %= m;
        if(i < childs.size()-1) {
            cur = ((rightdp[i+1] * curdp[i])%m) * dp[childs[i]];
            cur %= m;

        }
        cur = total - cur;
        cur %= m;
        // cout << childs[i] << " " << node << " " << cur << "\n";
        dfs2(childs[i], node, cur);
    }
  

    ans[node] = total;
    ans[node] %= m;

}


int main() {
    cin >> n >> m;
    edge.resize(n+1);
    // m = 100000000;

    for(int i = 0; i < n-1; ++i) {
        int u, v; cin >> u >> v;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }

    dfs(1, 0);
    dfs2(1, 0, 0);
    for(int i = 1; i <= n; ++i) {
        cout << (ans[i] + m) %m<< "\n";
    }

}

Measured memory_bytes: 23040
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
    char suit;
    int value;
};

struct Card L[MAX/2+2],R[MAX /2 +2];

void merge(struct Card A[], int n, int left, int mid,int right){
    int i, j, k ;
    int n1 = mid - left;
    int n2 = right - mid;
    for(i=0;i<n1;i++)L[i]=A[left+i];//左半分の数列を挿入
    for(i=0;i<n2;i++)R[i]=A[mid+i];//右半分の数列を挿入
    L[n1].value = R[n2].value = SENTINEL;
    i=j=0;
    for(k = left;k<right;k++){
        if(L[i].value<=R[j].value){
            A[k] = L[i++];
        }else{
            A[k] = R[j++];
        }
    }
}

void mergeSort(struct Card A[], int n, int left, int right){
    int mid;
    if(left +1 <right){// 要素数が1以上の場合
        mid = (left + right)/2;
        mergeSort(A,n,left,mid);
        mergeSort(A,n,mid,right);
        merge(A,n,left,mid,right);
    } 
}
int partition(struct Card A[], int n, int p, int r){
    int i,j;
    struct Card t,x;
    x= A[r];
    i = p-1;
    for(j=p; j<r;j++){
        if(A[j].value <= x.value){
            i++;
            t= A[i]; A[i]=A[j];A[j]=t;
        }
    }
    t = A[i+1];A[i+1]=A[r];A[r] = t;
    return i+1;
}

void quickSort(struct Card A[], int n, int p, int r){
    int q;
    if(p<r){
        q = partition(A,n,p,r);
        quickSort(A,n,p,q-1);
        quickSort(A,n,q+1,r);
    }
}

int main(){
    int n,i,v;
    struct Card A[MAX],B[MAX];
    char S[10];
    int stable =1;

    scanf("%d",&n);

    for(i=0;i<n;i++){
        scanf("%s %d",S,&v);
        A[i].suit = B[i].suit = S[0];
        A[i].value = B[i].value = v;
    }

    mergeSort(A,n,0,n);
    quickSort(B,n,0,n-1);

    for(i=0;i<n;i++){
        //マージソートとクイックソートの結果を比べる。(マージソートは安定なソート)
        if(A[i].suit != B[i].suit) stable =0;
    }
    if(stable == 1)printf("Stable\n");
    else printf("Not stable\n");
    for(i=0;i<n;i++){
        printf("%c %d\n",B[i].suit,B[i].value);
    }
    return 0;
}


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

using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;

	vector < int >A(N), B(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
	}

	vector < pair < int, int >>AB(N);
	for (int i = 0; i < N; i++) {
		AB[i] = make_pair(A[i], B[i]);
	}
	sort(AB.begin(), AB.end());

	long long ans = 0;
	for (int i = 0; i < N; i++) {
		int buy = min(AB[i].second, M);

		ans += (long long)AB[i].first * buy;
		M -= buy;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <cmath>
#include <cstdint>
#include <iostream>
#include <string>

using namespace std;

int64_t Atoi(const char* s, int len) {
  int64_t r = 0;
  int64_t e = 1;
  for (int i = len - 1; i >= 0; --i) {
    const auto n = (s[i] - '0');
    r += n * e;
    e *= 10;
  }
  return r;
}

int64_t Parse(const string& s, int i) {
  int64_t ret = 0;

  const char* ptr = s.data();
  int start = 0;
  int end = 1;
  for (int j = s.size() - 2; j >= 0; --j) {
    const auto mask = 1 << j;
    if (i & mask) {
      ret += Atoi(ptr + start, end - start);
      start = end;
    }
    ++end;
  }
  ret += Atoi(ptr + start, end - start);
  return ret;
}

int main() {
  string s;
  cin >> s;

  int64_t sum = 0;
  for (int i = 0; i < pow(2, s.size() - 1); ++i) {
    sum += Parse(s, i);
  }
  cout << sum << endl;

  return 0;
}


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

long long n,p[1005],cnt;
bool vis[1005];

void prime()
{
	for(long long i=2;i<=1000;i++){
		if(!vis[i]){
			p[++cnt]=i;
			for(long long j=i*i;j<=1000;j+=i) vis[j]=true;
		}
	}
}

long long calc(long long nn,long long cur){
	if(nn==0) return 0;
	long long res=0;
	res+=nn/cur+calc(nn/cur,cur);
	return res;
}

int main()
{
	long long ans=1;
    cin>>n;
    prime();
    for(long long i=1;i<=cnt&&p[i]<=n;i++){
    	long long val=calc(n,p[i]);
    	//cout<<p[i]<<" "<<val<<" "<<ans<<endl; 
    	ans*=(val+1);
    	ans%=INF;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
int n,a[305][305],ans;
char s[305];
int check1(int x){
	for (int i=0;i<n;i++)
		for (int j=0;j<n;j++)
			if (a[i][j]!=a[(j-x+n)%n][(i+x)%n]) return 0;
	return 1;
}
int check2(int x){
	for (int i=0;i<n;i++)
		for (int j=0;j<n;j++)
			if (a[i][j]!=a[(j+x)%n][(i-x+n)%n]) return 0;
	return 1;
}
int main(){
	scanf("%d",&n);
	for (int i=0;i<n;i++){
		scanf("%s",s);
		for (int j=0;j<n;j++) a[i][j]=s[j]-'a';		
	}
	for (int i=0;i<n;i++)
		ans=ans+check1(i)*(n-i);
	for (int i=1;i<n;i++)
		ans=ans+check2(i)*(n-i);
	printf("%d\n",ans);
	return 0; 
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
//Minute hand 6deg/min
//Hour hand 0.5deg/min
double pi=3.1415926535897932;

int main() {
  int a,b;
  int h,m;
  int t;
  cin>>a>>b>>h>>m;
  t=h*60+m;
  double disth=0.5*t;
  double distm=6*t;
  disth=disth-(((int)(disth/360))*360);
  distm=distm-(((int)(distm/360))*360);
  double Deg=fabs(disth-distm);
  double x=sqrt(a*a+b*b-2.0*a*b*cos(Deg*pi/180.0));
  cout<<fixed<<setprecision(15)<<x;
  return 0;
}

Measured memory_bytes: 4288
#include <iostream>
#include <string>

using namespace std;
int main(void){
    // Your code here!
    string s,t,h,d,answer;
    cin>>s>>t;
    h='H';
    d='D';
    if(s=="H"){
        if(t=="H"){
            answer=h;
        }
        else{
            answer=d;
        }
    }
    else{
        if(t=="H"){
            answer=d;
        }
        else{
            answer=h;
        }
    }
    cout<<answer<<endl;
}


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

int K, A, B;

int main() {
    cin >> K >> A >> B;
    bool isOK = false;
    for (int i = A; i <= B; i++) {
        if (i % K == 0 && i >= K) {
            isOK = true;
            break;
        }
    }
    if (isOK) {
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }
}

Measured memory_bytes: 3584
n = int(input())
a = list(map(int,input().split()))
ans = 1000000
a = sorted(a)
for i in range(a[0],a[n-1]+1):
    counter = 0
    for j in range(n):
        dif = abs(a[j] - i)
        dif *= dif
        counter += dif
    ans = min(ans,counter)
print(ans)

Measured memory_bytes: 3060
S = input()

if S == 'SSS':
    ans = 0
elif S == 'SSR':
    ans = 1
elif S == 'SRS':
    ans = 1
elif S == 'SRR':
    ans = 2
elif S == 'RSS':
    ans = 1
elif S == 'RSR':
    ans = 1
elif S == 'RRS':
    ans = 2
elif S == 'RRR':
    ans = 3

print(ans)

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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	int a[5];
	for(int i=0;i<5;i++)
		cin>>a[i];
	for(int i=0;i<5;i++){
		if(a[i]==0){
			cout<<i+1<<endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 3612
def abc119_d():
    import sys
    read = sys.stdin.buffer.read
    inp = iter(map(int, read().split()))

    a = next(inp)
    b = next(inp)
    q = next(inp)
    S = [next(inp) for _ in range(a)]
    T = [next(inp) for _ in range(b)]

    from bisect import bisect_left
    inf = 10**12

    for _ in range(q):
        x = next(inp)
        si = bisect_left(S, x)
        ti = bisect_left(T, x)

        sl, sr = inf, inf
        tl, tr = inf, inf
        if 0 < si: sl = x - S[si-1]
        if si < a: sr = S[si] - x
        if 0 < ti: tl = x - T[ti-1]
        if ti < b: tr = T[ti] - x

        ans = inf
        ans = min(ans, max(sl, tl))
        ans = min(ans, max(sr, tr))
        ans = min(ans, 2 * min(sl, tr) + max(sl, tr))
        ans = min(ans, 2 * min(sr, tl) + max(sr, tl))
        print(ans)

if __name__ == '__main__':
    abc119_d()

Measured memory_bytes: 33596
package main

import (
	"fmt"
)

func main() {
	var w, h, x, y float64
	fmt.Scan(&w, &h, &x, &y)

	ans := 0
	if x == w/2 && y == h/2 {
		ans = 1
	}
	fmt.Println(w*h/2, ans)
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#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, k; cin >> n >> k;
  if (n%k==0) cout << 0 << endl;
  else cout << 1 << endl;
  return 0;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n,k,q;cin>>n>>k>>q;
    vector<ll>cnt(n+1);
    rep(i,q){
        ll a;cin>>a;
        cnt[a]++;
    }
    rep(i,n){
        cout<<(k-q+cnt[i+1]>0?"Yes":"No")<<endl;
    }
}

Measured memory_bytes: 1408
#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 a;
	string s;
	cin >> a >> s;
	if (a < 3200) s = "red";
	cout << s << '\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: 3584
#include <climits>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#define fi first
#define se second
#define FO(x, n) for (int x = 0; x < n; ++x)
#define FOR(x, a, b) for (int x = a; x < b; ++x)
#define RFO(x, n) for (int x = n - 1; x >= 0; --x)
#define RFOR(x, a, b) for (int x = b - 1; x >= a; --x)
using namespace std;
typedef unsigned char byte;
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;
typedef pair<llong, llong> pll;
inline bool feq(const double& a, const double& b) { return fabs(a - b) < 1e-10; }

llong N, A, B;
llong hs[100100];

bool ok(llong k)
{
    llong base = k * B;
    llong* pt = upper_bound(hs, hs + N, base);
    size_t idx = pt - hs;
    llong cnt = 0;
    FOR (i, idx, N)
    {
        llong rest = hs[i] - base;
        cnt += rest / (A - B) + bool(rest % (A - B));
    }
    return cnt <= k;
}

int main()
{
    cin >> N >> A >> B;
    FO (i, N)
        cin >> hs[i];
    sort(hs, hs + N);
    llong l = 0, r = INT_MAX;
    while (l < r)
    {
        llong mid = (l + r) / 2;
        if (!ok(mid))
            l = mid + 1;
        else
            r = mid;
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 1024
def main():

    N = int(input())
    count = 0
    ansList = []

    for i in range(1,N+1):
        count = 0
        while(True):
            if i%2==0:
                count += 1
                i /= 2
            else:
                ansList.append(count)
                break

    print(ansList.index(max(ansList))+1)

    



    


if __name__== "__main__":
    main() 











Measured memory_bytes: 3060
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int num;
	scanf("%d",&num);
	vector<int>vec;
	for(int i=0;i<num;i++)
	{
		int z;
		scanf("%d",&z);
		vec.push_back(z);
	}
	sort(vec.begin(),vec.end());
	vec.push_back(2000000000);
	reverse(vec.begin(),vec.end());
	vec.push_back(0);
	for(int i=1;i<=num+1;i++)
	{
		if(vec[i]<i)
		{
			bool f=false;
			if(vec[i-1]!=i-1)
			{
				int c=vec[i-1]-(i-1);
				if(c%2!=0)f|=true;
			}
			if(vec[i]==i-1)
			{
				int c=0;
				for(int j=i;j<=num;j++)
				{
					if(vec[j]!=i-1)break;
					c++;
				}
				if(c%2!=0)f|=true;
			}
			if(f)printf("First\n");
			else printf("Second\n");
			break;
		}
	}
}


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

int main()
{
	
	string str;
	
	getline(cin , str);
	
	for(int i = 0; i < str.size(); i++){
		if('a' <= str[i] && str[i] <= 'z'){
			str[i] -= 32;
		}
	}
	
	cout << str << endl;
	
	return (0);
}

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

int main() {
    string s, t;
    cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    if (s < t) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

typedef std::map<uint32_t, uint32_t> IntIntMap;

int main(){
    vector <uint64_t> intNum;

    int N,Q;
    cin >> N >>Q; 
    intNum.reserve(N+1);
    IntIntMap abMap;

    for(int i=0;i<N-1;i++){
        uint32_t temp1,temp2;
        cin>>temp1 >> temp2;
        abMap.insert(std::make_pair(temp2,temp1));
    }

    for(int i=0;i<Q;i++){
        uint32_t temp1,temp2;
        cin>>temp1 >> temp2;
        intNum[temp1-1] += temp2; 
    }

    for(int i=1;i<N;i++){
        intNum[i] +=intNum[abMap[i+1]-1];
    }

    for(int i=0;i<N;i++){
        cout<< intNum[i]<<" ";
    }

    cout<<endl;

}



Measured memory_bytes: 13312
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  string s; cin >> s;
  ll r=0,b=0,g=0;
  ll mns=0;
  rep(i,n){
    if(s[i]=='R') r++;
    if(s[i]=='B') b++;
    if(s[i]=='G') g++;
    for(int j=i+1;j<n;j++){
      if(s[i]!=s[j]){
        int d=j-i;
        if(j+d<n&&s[j+d]!=s[i]&&s[j+d]!=s[j]) mns++;
      }
    }
  }
  ll ans=r*b*g-mns;
  cout << ans << endl;
  
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
string st,st2="CODEFESTIVAL2016";
int g;
int main()
{
	cin>>st;
	for(int i=0; i<16; i++)
	{
		if(st[i]!=st2[i])g++;
	}
	cout<<g<<endl;
	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <map>
#include <string>
using namespace std;

typedef long long ll;
const ll mod = 1e9+7;

int main() {
    int N;
    string S;
    cin >> N;
    cin >> S;
    map<char, int> m;
    for (int i=0; i<N; i++) {
            m[S[i]]++;
    }
    map<char, int>::iterator it;
    ll ans = 1;
    for(it = m.begin(); it != m.end(); it++) {
        ans *= it->second + 1;
        ans %= mod;
    }
    cout << ans - 1 << endl;
}


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

int main() {
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  bool ans=1;
  if(e-a>k) ans=0;
  if(ans) cout<<"Yay!"<<endl;
  else cout<<":("<<endl;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

	ll n,k;
	cin>>n>>k;

	if(n>k)n=n%k;

	cout<<min(n,abs(n-k))<<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++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    int n, m; cin >> n >> m;
    vector<string> a(n), b(m);
    rep(i, n) cin >> a.at(i); 
    rep(i, m) cin >> b.at(i); 

    bool ok = true;
    for(int i=0; i<=n-m; i++){
        for(int j=0; j<=n-m; j++){
            for(int k=0; k<m; k++){
                for(int l=0; l<m; l++){
                    if(a.at(k+i).at(l+j)==b.at(k).at(l)){continue;}
                    else{
                        ok = false;
                        break;
                    }
                }
           }

           if(ok){
               cout << "Yes" << endl;
               return 0;
           }
           else{
               ok = true;
           }
       }
    }
    
    cout << "No" << endl;
    return 0;
}


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

int main(){
    int N;  cin >> N;
    vector<int> p(N+1);
    for(int i=1; i<=N; i++) cin >> p[i];
    
    int ans = 0;
    for(int i=1; i<N; i++){
        if(p[i]==i){
            swap(p[i], p[i+1]);
            ans++;
        }
        if(i==N-1 && p[i+1] == i+1){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640