akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
#include <iostream>

int main()
{
  long n;
  long array[100001];

  scanf("%ld", &n);

  for(long i = 0; i < n; i++)
    scanf("%ld", &array[i]);

  std::sort(array, array + n);
  std::reverse(array, array + n);

  long match[100001];
  long counter = 0;

  for(long i = 0; i < n; i++)
  {
    if(array[i] == array[i + 1])
    {
      match[counter] = array[i];
      counter++;
      i++;
    }
  }
  if(counter < 2)
    printf("%d\n", 0);

  else
    printf("%ld\n", match[0] * match[1]);
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>

namespace NS20200711Acing
{

  class AnOddProblem final
  {
  public:
    AnOddProblem() = default;
    ~AnOddProblem() = default;

  public:
    void Run()
    {
      Input();
      Calc();
      Output();
    }

    void Input()
    {

      std::cin >> m_N;
      for (int i = 0; i < m_N; ++i)
      {
        std::cin >> m_A[i];
      }
    }

    void Calc()
    {
      for(int i=0;i<m_N;i+=2)
      {
        if((m_A[i] & 0x1) == 1) m_answer++;
      }
    }

    void Output()
    {
      std::cout << m_answer << std::endl;
    }

  private:
    static const int N_MAX = 100;
    int m_N;
    int m_A[N_MAX] = {};
    int m_answer = 0;
  };

}

int main()
{
  NS20200711Acing::AnOddProblem prob;
  prob.Run();

  return 0;
}

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

signed main() {
  int N; cin >> N;
  int now = -1;
  int k = 2;
  int ans = 0;
  rep(i, N) {
    int a; cin >> a;
    if(a > now) {
      if(k == 2) {
        //cout << a << endl;
        ans++;
        k = 0;
      } else if(k == 0) {
        k = 1;
      }
    }
    if(a < now) {
      if(k == 1) {
        //cout << a << endl;
        ans++;
        k = 0;
      } else if(k == 0) {
        k = 2;
      }
    }
    now = a;
  }
  cout << ans << endl;

}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
# define pb push_back
# define FOR(i,a,n) for(int i=a;i<n;i++)
# define mp make_pair
# define RFOR(i,a,n) for(int i=n;i>a;i--)
# define pii pair<long long int,long long int>
#define ub upper_bound
#define lb lower_bound
#define MOD 1000000007
typedef long long int ll;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
        cout.tie(0);
		ll n;
		cin>>n;
		ll ans;
		ans=n%1000;
		if(ans!=0)
		ans=1000-ans;
		cout<<ans<<endl;
	
}

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

int main() {
  ll n;
  cin >> n ;
  vector<vector<ll>> a(n,vector<ll>(3));
  rep(i,n){
    cin >> a[i][0] >> a[i][1] >> a[i][2];
  }
  vector<vector<ll>> dp(n+1,vector<ll>(3));
  for (int i = 1; i<n+1; i++){
    for (int j =0;j<3; j++){
      for (int k =0; k<3; k++){
        if (k==j) continue;
        dp[i][j]=max(dp[i-1][k]+a[i-1][j],dp[i][j]);
      }
    }
  }
  ll ans=0LL;
  rep(i,3){
    ans=max(ans,dp[n][i]);
  }
  cout <<ans <<endl;
  return 0;
}


Measured memory_bytes: 11136
import sys
import math
import random

def isPrime(q):
    if q==2:
        return True
    if q<2:
        return False
    if pow(2,q-1,q)==1:
        return True
    else:
        return False

def f(x,c,n):
    return (x**2+c)%n

def rho(n):
    x=random.randint(0,n-1)
    y=random.randint(0,n-1)
    c=random.randint(1,n-3)
    d=math.gcd(abs(x-y),n)
    while d==1:
        print(d)
        x=f(x,c,n)
        y=f(y,c,n)
        y=f(y,c,n)
        d=math.gcd(abs(x-y),n)
        if d==n:
            break

    return d


def main():
    N=int(input())

    P={}

    # d=rho(N)
    # P[d]=1
    #
    # while N>d:
    #     N=N//d
    #     d=rho(N)
    #     if (d in P.keys()):
    #         P[d]+=1
    #     else:
    #         P[d]=1

    if isPrime(N):
        print("1")
        sys.exit()

    for i in range(2,N):
        if N%i==0:
            P[i]=1
            N=N//i
            while N%i==0:
                N=N//i
                P[i]+=1
            if isPrime(N):
                P[N]=1
                break
        if N==1:
            break

    counter=1
    res=0
    KEY=list(P.keys())
    while len(KEY)>0:
        for i in KEY:
            if P[i]-counter>=0:
                res+=1
                P[i]=P[i]-counter
            else:
                KEY.remove(i)
                P.pop(i,None)
        counter+=1

    print(res)


if __name__ == "__main__":
    main()

Measured memory_bytes: 76828
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N; cin >> N;
  string s; cin >> s;
  for(int i = 0; i < s.length(); i++){
    s[i] -= 'A';
    s[i] += N;
    s[i] %= 26;
    s[i] += 'A';
  }
  cout << s << endl;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep (i, h) cin >> s[i];
    int res = 0;
    rep (bit, 1 << h) {
        vector<bool> row(h);
        rep (i, h) {
            if (bit & (1 << i)) row[i] = true;
        }
        rep (b, 1 << w) {
            vector<bool> column(w);
            rep (j, w) {
                if (b & (1 << j)) column[j] = true;
            }
            int cnt = 0;
            rep (i, h) {
                if (row[i]) continue;
                rep (j, w) {
                    if (column[j]) continue;
                    if (s[i][j] == '#') cnt++;
                }
            }
            res += cnt == k;
        }
    }
    cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
const int INF=1e9+5;
const int N=2e5+5;
const int mod=1e9+7;


int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	string s;
	cin>>n>>s;
	//~ R W
	int cnt=0;
	for(int i=0;i<n;++i){
		if(s[i]=='R') ++cnt;
	}
	int ans=0;
	for(int i=0;i<cnt;++i){
		if(s[i]=='W') ++ans;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3752
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <set>
#include <unordered_set>
#include <stack>
#include <algorithm>
#include <queue>
#include <ctime>
#include <iomanip>
#include <tuple>
#include <functional>
#include <map> 
#include <numeric> 

using namespace std;


#define ll long long
#define pi pair<int, int>
#define vi vector<int>
#define vp vector<pi>
#define msa(A, a, n) memset(A, a, n*sizeof(A))
#define msv(A, a) fill(A.begin(), A.end(), a);
#define msc(A, n) memset(A, '\0', n)
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define rep(i, a, b) for(int i = a; i < b; i++)
#define per(i, a, b) for(int i = a; i >= b; i--)
#define pern(i, b) per(i, b - 1, 0)
#define repn(i, b) rep(i, 0, b)
#define repe(i, a, b) for(int i = a; i <= b; i++)
#define repen(i, b) repe(i, 1, b)
#define fast ios_base::sync_with_stdio();cin.tie(0);
#define endl "\n"
//#define MYDEBUG

void my_return(int code)
{
#ifdef MYDEBUG
	std::cout << "\n\nTime = " << fixed << std::setprecision(3) << double(clock()) / CLOCKS_PER_SEC << endl;
#endif
	exit(code);
}

int main()
{
	fast
#ifdef MYDEBUG
		freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll a, b, c, d;
	cin >> a >> b >> c >> d;

	ll x = 0, y = 0;

	x = max(a * c, a * d);
	y = max(b * c, b * d);
	cout <<max(x, y) << endl;

	my_return(0);
}


Measured memory_bytes: 3632
i = []
gets.split(" ").each do |n|
    i << n.to_i 
end

if (i[0] - i[1]) > 1
    puts i[0] + (i[0] - 1)
elsif (i[0] - i[1]) < -1
    puts i[1] + (i[1] - 1)
else
    puts i[0] + i[1]
end

Measured memory_bytes: 1788
using System;
using System.Collections.Generic;
using System.Linq;
namespace CsProgramSpace
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            short b, f, r, v;
            short[][] a1 = new short[3][];//4,3,10
            short[][] a2 = new short[3][];
            short[][] a3 = new short[3][];
            short[][] a4 = new short[3][];
            for (int j=0;j<3;j++)
            {
                a1[j] = new short[10];
                a2[j] = new short[10];
                a3[j] = new short[10];
                a4[j] = new short[10];
                for (int k = 0; k<10;k++)
                {
                    a1[j][k] = 0;
                    a2[j][k] = 0;
                    a3[j][k] = 0;
                    a4[j][k] = 0;
                }
            }
            
            for (int i = 0; i < n; i++)
            {
                short[] inf = (Console.ReadLine().Split(' ').Select(_ => short.Parse(_)).ToArray());
                b = inf[0];f = inf[1];r = inf[2];v = inf[3];
                if (b == 1)
                    a1[f - 1][r - 1] += v;
                else if(b==2)
                    a2[f - 1][r - 1] += v;
                else if (b == 3)
                    a3[f - 1][r - 1] += v;
                else if (b == 4)
                    a4[f - 1][r - 1] += v;
            }
            int cnt = 0;
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    for (int k = 0; k < 10; k++)
                    {
                        if (cnt == 0)
                            Console.Write(" " + a1[j][k]);
                        else if (cnt == 1)
                            Console.Write(" " + a2[j][k]);
                        else if (cnt == 2)
                            Console.Write(" " + a3[j][k]);
                        else if (cnt == 3)
                            Console.Write(" " + a4[j][k]);
                    }
                    Console.WriteLine();
                }
                if (i != 3) Console.WriteLine("####################");
                cnt++;
            }
        }
    }
}


Measured memory_bytes: 18368
n,k = map(int,input().split())
if k>(n-1)*(n-2)//2:
    print(-1)
    exit()

ans = n*(n-1)//2-k
print(ans)
count = 0
for i in range(1,n):
    for j in range(i+1,n):
        count += 1
        if count > k:
            print(i,j)

    print(i,n)

Measured memory_bytes: 43504
package main

import (
	"fmt"
	"math"
)

func main() {
	var str string
	fmt.Scan(&str)
	
	var max float64
	var count float64
	for _, c := range str {
		if c == 'A' || c == 'C' || c == 'G' || c == 'T' {
			count++
		} else {
			count = 0
		}
		max = math.Max(max, count)
	}
	
	fmt.Print(max)
}

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

void we_r_done(){cout<<"NO"; exit(0);}

void debug(string mssg){cout<<mssg; exit(0);}

using minHeap = priority_queue< int, vector< int >, greater< int > >;

#define N  200001

lli tree[N*4] , dp[N];

lli get_max(int idx , int lo , int hi , int l , int r)
{
    if(l>r)return 0;

    if(hi<l || lo>r)return 0;

    if(l<=lo && hi<=r)return tree[idx];

    int mid = (lo+hi)/2;

    return max(get_max(idx*2,lo,mid,l,r),get_max(idx*2+1,1+mid,hi,l,r));
}

void update(int idx , int lo , int hi ,int pos)
{
    if(hi<pos || lo>pos)return;

    if(lo == hi){
        tree[idx] = dp[pos];
        return ;
    }

    int mid = (lo+hi)/2;

    update(idx*2,lo,mid,pos);
    update(idx*2+1,1+mid,hi,pos);

    tree[idx] = max(tree[idx*2] , tree[idx*2 +1]);
}

int main()
{
    ///freopen("output.txt","w",stdout);
    ///freopen("input.txt","r",stdin);

    ///FastIO;
    int n;
    scn(n);
    int h[n+1],a[n+1];

    for(int i=1; i<=n; i++)scn(h[i]);
    for(int i=1; i<=n; i++)scn(a[i]);

    for(int i=1; i<=n; i++){

        dp[h[i]] = get_max(1,1,n,1,h[i]-1) + a[i];
        //cout<<dp[h[i]]<<endl;
        update(1,1,n,h[i]);
    }
    //cout<<get_max(1,1,n,1,3)<<" "<<tree[2]<<endl;
    lli ans = 0;
    for(int i=1; i<=n; i++) ans= max(ans , dp[i]);
    cout<<ans;

    return 0;

}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?


Measured memory_bytes: 7936
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int N;
long D,A;
vector<pair<int,int> >H;
main()
{
	cin>>N>>D>>A;
	for(int i=0;i<N;i++)
	{
		int x,h;cin>>x>>h;
		H.push_back(make_pair(x,h));
	}
	sort(H.begin(),H.end());
	queue<pair<long,int> >P;
	long cnt=0,ans=0;
	for(int i=0;i<N;i++)
	{
		while(!P.empty()&&P.front().first<H[i].first)
		{
			cnt-=P.front().second;
			P.pop();
		}
		long nowh=H[i].second;
		nowh-=cnt*A;
		if(nowh>0)
		{
			long t=(nowh+A-1)/A;
			ans+=t;
			cnt+=t;
			P.push(make_pair(H[i].first+D*2,t));
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3440
# https://atcoder.jp/contests/abc092/tasks/abc092_a

import itertools
import collections
import bisect

def main():
    A = int(input())
    B = int(input())
    C = int(input())
    D = int(input())
    print(min(A, B) + min(C, D))


if __name__ == '__main__':
    main()



Measured memory_bytes: 3316
n, a, b = map(int,input().split())

result_sum = 0
for i in range(1,n+1):
    keta_sum = 0
    for j in range(len(str(i))):
        keta_sum += int(str(i)[j])

    if a <= keta_sum and b >= keta_sum:
        result_sum += i
    keta_sum = 0

print(result_sum)



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

int main(){
  int H,W;
  while(1){
    cin >> H >> W;
    if(H==0 && W==0) break;

    bool flag = true;
    for(int i=0;i<H;i++){
      if(i%2==0) flag = true;
      else flag = false;
      for(int j=0;j<W;j++){
        if(flag){
          cout << "#";
          flag = false;
        }else{
          cout << ".";
          flag = true;
        }
      }
      cout << endl;
    }
    cout << endl;
  }

  return 0;
}
      

Measured memory_bytes: 1152
main :: IO ()
main = do
  [a,b,c,k] <- map read . words <$> getLine
  let res = solve a b c k
  putStrLn $ if res > 10^18 then "Unfair" else show res

solve :: Int -> Int -> Int -> Int -> Int
solve a b c k | even k = a - b
                    | otherwise = b - a


Measured memory_bytes: 508
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define dprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define dprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

//const double PI = 3.1415926535897932384626433832795;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  bool poor = false;
  if((a == b && b != c)
      || (a == c && b != c)
      || (b == c && b != a)
  ) {
    poor = true;
  }
  if(poor) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
    
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string S,T;
    cin >> S >> T;
    
    bool match=true;
    
    if(S.size()+1!=T.size()) {
        cout << "No" << endl;
        match=false;
    }
     else { 
         for (int i=0;i<S.size();i++) 
          if(S[i]!=T[i]) {
              cout << "No" << endl;
              match=false;
              break;
          }
     
    }
    
    if(match==true) {
        cout << "Yes" << endl;
    }
    
    
}


Measured memory_bytes: 3608
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  ll X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<ll> p(A), q(B), r(C);
  for (int i = 0; i < A; i++) cin >> p[i];
  for (int i = 0; i < B; i++) cin >> q[i];
  for (int i = 0; i < C; i++) cin >> r[i];
  sort(p.begin(), p.end(), greater<ll>());
  sort(q.begin(), q.end(), greater<ll>());
  sort(r.begin(), r.end(), greater<ll>());
  vector<ll> x(X), y(Y);
  for (int i = 0; i < X; i++) x[i] = p[i];
  for (int i = 0; i < Y; i++) y[i] = q[i];
  pair<ll, ll> cur_xy = {X - 1, Y - 1};
  ll x_i, y_i;
  bool both_is_valid, x_is_valid, y_is_valid, x_is_target, y_is_target;
  for (int i = 0; i < C; i++) {
    x_i = cur_xy.first;
    y_i = cur_xy.second;
    both_is_valid = (x_i >= 0 && y_i >= 0);
    x_is_valid = (x_i >= 0);
    y_is_valid = (y_i >= 0);
    if (both_is_valid) {
      x_is_target =
          (x[x_i] < y[y_i] || (x[x_i] == y[y_i] && Y <= X)) && x[x_i] < r[i];
      y_is_target =
          (y[y_i] < x[x_i] || (x[x_i] == y[y_i] && X <= Y)) && y[y_i] < r[i];
      if (x_is_target) {
        x[x_i] = r[i];
        cur_xy.first--;
      } else if (y_is_target) {
        y[y_i] = r[i];
        cur_xy.second--;
      } else {
        break;
      }
    } else if (x_is_valid && x[x_i] < r[i]) {
      x[x_i] = r[i];
      cur_xy.first--;
    } else if (y_is_valid && y[y_i] < r[i]) {
      y[y_i] = r[i];
      cur_xy.second--;
    } else {
      break;
    }
  }
  ll ans = 0;
  for (ll x_element : x) ans += x_element;
  for (ll y_element : y) ans += y_element;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3968
n=int(input())
l=[]
for i in range(n):
    x=input()
    l.append(x)
a=0
b=0
c=0
d=0
for e in l:
    if e=='AC':
        a=a+1
    elif e=='WA':
        b=b+1
    elif e=='TLE':
        c=c+1
    elif e=='RE':
        d=d+1
print("AC x "+str(a))
print("WA x "+str(b))
print("TLE x "+str(c))
print("RE x "+str(d))

Measured memory_bytes: 16244
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    ll N,A,B; cin >> N >> A >> B;
    ll ans, ans1, ans2;
    if((B-A)%2){
        ans1 = min(B-1, N-A);
        if(N-B > A-1){
            ans2 = A;
            ans2 += (B-A-1)/2;
        } else{
            ans2 = N-B+1;
            ans2 += (B-A-1)/2;
        }
        ans = min(ans1,ans2);
    }
    else{
        ans = (B-A)/2;
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  ll t1,t2,a1,a2,b1,b2;cin>>t1>>t2>>a1>>a2>>b1>>b2;

  if(t1*a1+t2*a2==t1*b1+t2*b2) { cout<<"infinity"<<endl; return 0; }

  // A always runs long
  if(t1*a1+t2*a2<t1*b1+t2*b2) {
    swap(a1,b1);
    swap(a2, b2);
  }

  if(a1>b1) { cout<<0<<endl; return 0; }

  ll diff = (t1*a1+t2*a2) - (t1*b1+t2*b2);

  ll t1_diff = b1*t1-a1*t1;
  if(t1_diff==diff) { cout<<2<<endl; return 0; }

  ll result=(t1_diff/diff)*2;
  if(t1_diff%diff!=0)result++;
  cout<<result<<endl;

//cout<<t1_diff<<' '<<diff<<endl;

  return 0;
}

Measured memory_bytes: 3540
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
const int N=3e5+2;
int x[N],y[N];
int32_t main()
{
  #ifndef ONLINE_JUDGE
  freopen("in","r",stdin);
  freopen("out","w",stdout);
  #endif

  int n,m,a,b,t;
  set<pair<int,int>> s;
  cin>>n>>m>>t;
  for(int i=0;i<t;i++)
  {
    cin>>a>>b;
    s.insert({a,b});
    x[a]++;y[b]++;
  }
  
  int mxx=*max_element(x,x+n+1);int mxy=*max_element(y,y+m+1);
  vector<int> xx,yy;
  for(int i=0;i<=max(n,m);i++)
  {
    if(x[i]==mxx)
    xx.push_back(i);
    if(y[i]==mxy)
    yy.push_back(i);
  }
  
 
  for(auto i:xx)
    for(auto j:yy)
    {
      
      if(s.find({i,j})==s.end())
      {cout<<mxx+mxy;return 0;}
      
    }
    
  cout<<mxx+mxy-1;

}

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

void printLCS(vector < vector < int > > &dp, string s1, string s2, int n1, int n2, string &result) {
  if (n1 == 0 || n2 == 0) {
    return;
  }

  if (s1[n1 - 1] == s2[n2 - 1]) {
    result.push_back(s1[n1 - 1]);
    printLCS(dp, s1, s2, n1 - 1, n2 - 1, result);
  } else {
    if (dp[n1 - 1][n2] > dp[n1][n2 - 1]) {
      printLCS(dp, s1, s2, n1 - 1, n2, result);
    } else {
      printLCS(dp, s1, s2, n1, n2 - 1, result);
    }
  }

}

string iterativeLCS(string s1, string s2) {
  int n1 = s1.length();
  int n2 = s2.length();
  vector < vector < int > >dp(n1 + 1, vector < int >(n2 + 1, 0));

  for (int i = 1; i <= n1; i++) {
    for (int j = 1; j <= n2; j++) {
      if (s1[i - 1] == s2[j - 1]) {
        dp[i][j] = dp[i - 1][j - 1] + 1;
      } else {
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
      }
    }
  }

  // cout<<"printing dp table"<<endl;
  // for (int i = 0; i < n1 + 1; i++) {
  //   for (int j = 0; j < n2 + 1; j++) {
  //     cout<<dp[i][j]<<" ";
  //   }
  //   cout<<endl;
  // }

  string result = "";
  printLCS(dp, s1, s2, n1, n2, result);
  // cout<<"result = "<<result<<endl;
  reverse(result.begin(), result.end());
  return result;
}


int main() {
  // int test;
  // cin>>test;
  // while (test--) {
    string s1;
    cin>>s1;
    string s2;
    cin>>s2;
    // cout<<lcs(s1, s2)<<endl;
    // cout<<"iterative version "<<endl;
    cout<<iterativeLCS(s1, s2)<<endl;
  // }
  return 0;
}


Measured memory_bytes: 68552
#include <iostream>

using namespace std;

int main()
{
	int A, B;
	cin >> A >> B;

	for (int x = 1; x <= 10 * 1000 * 1000; ++x) {
		int taxA = x * 8 / 100;
		int taxB = x * 10 / 100;
		if (taxA == A && taxB == B) {
			cout << x << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String text = sc.next();
        int numR = 0;
        int maxR = 0;
        for (int i = 0; i < text.length(); i++){
            if (text.charAt(i) == 'R'){
                numR++;
            } else {
                numR = 0;
            }

            if (numR >= maxR){
                maxR = numR;
            }
        }
        System.out.println(maxR);
    }
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
typedef vector<pi> vp;

#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define INF 1e9
#define modulo 1000000007
#define forn(i, n) for(int i = 0; i < (n); i++)
#define FAST ios::sync_with_stdio(false); cin.tie(NULL);
#define end1 "\n" 
#define print(x) cout << x << end1
#define debug(x) cout<< #x <<" :: "<< x <<end1;
#define debug2(x, y) cout<< #x <<" :: "<< x << "\t" << #y <<" :: "<< y <<end1;



int main(){ 
FAST;
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif

////////
int n; cin >> n;

long double ans = 2*PI*n;

cout << fixed << setprecision(7) << ans << end1;

return 0;
}

Measured memory_bytes: 3800
N,K = list(map(int, input().split()))
R,S,P = list(map(int, input().split()))
T = list(map(str, input()))

res = 0

def change(hand):
    if hand == 'r':
        return 'p'

    if hand == 's':
        return 'r'

    if hand == 'p':
        return 's'

memo = []
for (i,t) in enumerate(T):
    if i > K-1:
        if memo[i-K] == change(t):
          memo.append(' ')
          continue
 
    if t == 'r':
        res = res+P
        memo.append(change(t))

    if t == 's':
        res = res+R
        memo.append(change(t))

    if t == 'p':
        res = res+S
        memo.append(change(t))

print(res)
    



Measured memory_bytes: 4804
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, a, b = list(map(int, input().rstrip('\n').split()))
    h = [int(input().rstrip('\n')) for _ in range(n)]
    cor_v = 10 ** 16
    inc_v = -1
    while cor_v - inc_v > 1:
        bin_v = (cor_v + inc_v) // 2
        cost = 0
        #条件を満たすcostを全検索
        for i in range(n):
            hp = h[i] - bin_v * b
            if hp > 0:
                cost += (hp + (a - b) - 1) // (a - b)
        #costが制約を満たすか
        if cost <= bin_v:
            cor_v = bin_v
        else:
            inc_v = bin_v
    print(cor_v)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 46300
from collections import deque

h,w=[int(i) for i in input().split() ]

graph=[[None for i in range(w+2)] for j in range(h+2)]
wnum=0
for i in range(w+2):
    graph[0][i]=['#',None]
    graph[h+1][i]=['#',None]
for j in range(h+2):
    graph[j][0]=['#',None]
    graph[j][w+1]=['#',None]
for i in range(h):
    a=input()
    for j in range(w):
        if a[j]=='.':
            wnum+=1
        graph[i+1][j+1]=[a[j],None]

q=deque([])
q.append((1,1))
graph[1][1][1]=0
d_min=None
while len(q)!=0:
    x,y=q.popleft()
    for cx,cy in ((x-1,y),(x+1,y),(x,y-1),(x,y+1)):
        if graph[cx][cy][0]=='.':
            if graph[cx][cy][1]==None:
                graph[cx][cy][1]=graph[x][y][1]+1
                if (cx,cy)==(h,w):
                    d_min=graph[cx][cy][1]
                    break
                q.append((cx,cy))
if d_min!=None:
   print(wnum-d_min-1)
else:
   print(-1)


Measured memory_bytes: 3564
#include <cstdio>
#define ll unsigned long

int main() {
  int n, f = 0;
  scanf("%d", &n);
  ll o = 1, t;
  for(int i = 0; i < n; i++) {
    scanf("%lu", &t);
    if(!t) {
      printf("0\n");
      return 0;
    }
    if(__UINT64_MAX__ / o >= t)
      o *= t;
    else
      f = 1;
  }
  if(f || o > (ll)1e18)
    printf("-1\n");
  else
    printf("%lu\n", o);
}

Measured memory_bytes: 1732
import heapq

n = int(input())
V = list(map(int, input().split()))

heapq.heapify(V)

for i in range(n-1):
    a = heapq.heappop(V)
    b = heapq.heappop(V)
    heapq.heappush(V, (a+b)/2)

print(V[0])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  string sa, sb, sc;
  cin >> sa >> sb >> sc;
  char now = 'a';
  while (true) {
    if (now == 'a') {
      if (sa.size() == 0) {
        cout << 'A' << endl;
        return 0;
      }
      now = sa[0];
      sa.erase(sa.begin());
    } else if (now == 'b') {
      if (sb.size() == 0) {
        cout << 'B' << endl;
        return 0;
      }
      now = sb[0];
      sb.erase(sb.begin());
    } else {
      if (sc.size() == 0) {
        cout << 'C' << endl;
        return 0;
      }
      now = sc[0];
      sc.erase(sc.begin());
    }
  }
}

Measured memory_bytes: 3632
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int x, y, z; cin >> x >> y >> z;
	int ans = min({ x + y,y + z,z + x });
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <complex>
#include <cmath>

using namespace std;

typedef complex<double> P;

struct L {
	P p, q;
	L(P p, P q) : p(p), q(q) {}
};

const double EPS = 1e-8;
const double PI  = acos(-1);

double dot(P a, P b) { return real(conj(a)*b); }
double cross(P a, P b) { return imag(conj(a)*b); }
double angle(P a, P b) { return arg(conj(a)*b); }

P footPerp(L l, P p) {
	return l.p + (l.q-l.p)*(dot(l.q-l.p, p-l.p) / (abs(l.q-l.p)*abs(l.q-l.p)));
}

double distLP(L l, P p){
	return abs(cross(l.q-l.p,p-l.p))/abs(l.q-l.p);
}

bool spIntersect(L l, P p){
	return abs(abs(l.p-p)+abs(l.q-p)-abs(l.p-l.q)) < EPS;
}

int main(){
	int N, A, B;
	P p[30], q[4];
	const string res[4] = {"Red", "Green", "Blue", "White"};
	while(cin >> N >> A >> B){
		for(int i=0;i<N;i++) cin >> p[i].real() >> p[i].imag();
		q[3] = P(A, (p[1]-p[0]).imag()/(p[1]-p[0]).real()*(A-p[0].real())+p[0].imag());
		q[0] = q[3] + (p[1]-p[0])/abs(p[1]-p[0]);
		q[2] = q[3] + (q[0]-q[3])*P(0,1);
		q[1] = q[2] + (q[3]-q[2])*P(0,1);
		int cur = 0;
		int last = 0;

		while(q[cur].real() < B){
			int next = (cur+1)%4;
			double rot = -0.5*PI;
			for(int i=last;i+1<N;i++){
				L l = L(p[i], p[i+1]);
				double dist = distLP(l, q[cur]);
				for(int j=1;j<=2;j++){
					if(distLP(l, q[cur]) < sqrt((double)j)+EPS){
						P f = footPerp(l, q[cur]);
						for(int k=-1;k<=1;k+=2){
							P c = f + k/abs(p[i+1]-p[i])*sqrt(j-dist*dist)*(p[i+1]-p[i]);
							if(spIntersect(l, c)){
								double tmp = angle(q[(cur+j)%4]-q[cur], c-q[cur]);
								if(tmp > EPS) continue;
								if(tmp > rot){
									last = i;
									next = (cur+j)%4;
									rot = tmp;
								}
							}
						}
					}
				}
			}
			for(int i=1;i<=3;i++)
				q[(cur+i)%4] = q[cur] + (q[(cur+i)%4]-q[cur])*P(cos(rot), sin(rot));
			cur = next;
		}
		cout << res[cur] << endl;
	}
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main()
{
    int t;
    cin>>t;
    int co=0;
    int flag=0;
   for(int i=0;i<t;i++)
   {
       int a,b;
       cin>>a>>b;
       if(a==b)
       {
           co++;
           if(co==3)
           {
               cout<<"Yes"<<endl;
               flag=1;
               break;
           }
       }
       else
       {
           co=0;
       }
   }
   if(flag==0)
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3132
#include<stdio.h>
int main(void){
char S[5];
scanf("%s",S);
if( (S[0]==S[1]) ||
     (S[1]==S[2]) ||
      (S[2]==S[3])){
          printf("Bad\n");
      }else{
          printf("Good\n");
      }
return 0;
}

Measured memory_bytes: 128
x,n = map(int,input().split())

if n != 0:
  s = set(list(map(int,input().split())))
else:
  s = []
diff = 10**18
ans = 10**18
  
for i in range(-10000, 10000):
  if i in s:
    continue
  else:
    if abs(x - i) < diff:
      ans = i
      diff = abs(x - i)
      
print(ans)

Measured memory_bytes: 9172
import java.util.Scanner;

class Main {
	static StringBuilder sb = new StringBuilder("");
	static int index = 0;
	
	public static void main(String args[]) {
		run();
	}
	public static void run() {
		Scanner scanner = new Scanner(System.in);
		int  num = scanner.nextInt();//要素数
		Node[] nodes = new Node[num];
		int[] preorder = new int[num];
		int[] inorder = new int[num];
		
		//入力ごとに配列
		for (int i = 0; i < num; i++) {
			preorder[i] = scanner.nextInt();
		}
		for (int i = 0; i < num; i++) {
			inorder[i] = scanner.nextInt();
		}
		
		Reconstruction(nodes, preorder, inorder, 0, num);
		
		output();//出力関数
		
		scanner.close();
	}
	
	//
	public static int Reconstruction(Node[] nodes, int[] preorder, int[] inorder, int right, int left) {
		 if (left == right) {
			 return -1;
		 }
		
		int sub = index;
		index ++;
		
		// root探し
		int root = 0;
		outside: for (int i = 0; i < preorder.length; i++) {
			for (int j = right; j < left; j++) {
				if (preorder[i] == inorder[j]) {
					root = j;
					break outside;
				}
			}
		}
		
		
		//左右に分けて処理
		nodes[sub] = new Node(inorder[root], -1, -1);
		nodes[sub].left = Reconstruction(nodes, preorder, inorder, right, root);
		nodes[sub].right = Reconstruction(nodes, preorder, inorder, root + 1, left);
		
		sb.append(" ").append(nodes[sub].id);
		
		return sub;
	}
	
	//出力
	public static void output(){
		sb.deleteCharAt(0);//重複してるroot消し
		System.out.println(sb);
	}
}
class Node{
	public int id;
	public int left;
	public int right;
	
	public Node(int id, int left, int right) {
		this.id = id;
		this.left = left;
		this.right = right;
	}
	
}



Measured memory_bytes: 26420
#include <cstdio>
#include <cstring> 

using namespace std;
const int MOD(998244353);
const int Max_N(405);
const int Max_SumA(405);
const int Max_SumB(405);
typedef long long int LL;

constexpr int Mult(int a, int b)
{
	return a * 1LL * b % MOD;
}

constexpr int Add(int a, int b)
{
	return a + b >= MOD ? a + b - MOD : a + b;
}

constexpr int Sub(int a, int b)
{
	return a - b < 0 ? a - b + MOD : a - b;
}

constexpr int squ(int a)
{
	return Mult(a, a);
}

void exgcd(int a, int b, int &x, int &y)
{
	if (b == 0)
		x = 1, y = 0;
	else
		exgcd(b, a % b, y, x), y -= x * (a / b);
}

inline int inverse(int a)
{
	int invx, invy;
	exgcd(a, MOD, invx, invy);
	return (invx % MOD + MOD) % MOD;
}

inline void upd(int &a, int b)
{
	a = Add(a, b);
}

inline void inc(int &a, int b)
{
	a = Sub(a, b);
}

int N, A[Max_N], B[Max_N], F[2][Max_SumA][Max_SumB][2], Fac[Max_SumB], Inv[Max_SumB], now, lst;

inline int merge(int a, int b)
{
	return Mult(Fac[a + b], Mult(Inv[a], Inv[b]));
}

int main()
{
	scanf("%d", &N);
	for (int i = 1;i <= N;++i)
		scanf("%d%d", A + i, B + i), B[0] += B[i];
	Fac[0] = 1;
	for (int i = 1;i <= B[0];++i)
		Fac[i] = Mult(Fac[i - 1], i);
	Inv[B[0]] = inverse(Fac[B[0]]);
	for (int i = B[0] - 1;i >= 0;--i)
		Inv[i] = Mult(Inv[i + 1], i + 1);
	B[0] = 0;
	F[0][0][0][0] = Sub(0, 1), now = 0, lst = 1;
	for (int i = 1;i <= N;++i)
	{
		now ^= 1, lst ^= 1, memset(F[now], 0, sizeof(F[now]));
		for (int cnt = 0;cnt <= B[0];++cnt)
			for (int sump = 0, p;sump <= A[0];++sump)
			{
				for (int c = 0;c <= 1;++c)
				{
					if (!F[lst][cnt][sump][c])
						continue;
					upd(F[now][cnt][sump][c], F[lst][cnt][sump][c]);
					p = 1;
					for (int x = 0;x < B[i];++x, p = Mult(p, A[i]))
						inc(F[now][cnt + x][sump + A[i]][c], Mult(Mult(F[lst][cnt][sump][c], merge(cnt, x)), p));
				}
				if (!F[lst][cnt][sump][0])
					continue;
				p = 1;
				for (int x = 1;x <= B[i];++x)
					p = Mult(p, A[i]);
				inc(F[now][cnt + B[i] - 1][sump + A[i]][1], Mult(Mult(F[lst][cnt][sump][0], merge(cnt, B[i] - 1)), p));
			}
		B[0] += B[i], A[0] += A[i];
	}
	int Ans(0);
	for (int cnt = 0;cnt <= B[0];++cnt)
		for (int sump = 0, p, val, inv;sump <= A[0];++sump)
		{
			if (!(val = F[now][cnt][sump][1]))
				continue;
			p = Mult(sump, inverse(A[0]));
			val = Mult(val, Mult(cnt + 1, inverse(p))); 
			inv = inverse(sump);
			for (int i = 1;i <= cnt + 1;++i)
				val = Mult(val, inv);
			upd(Ans, val);
		}
	printf("%d", Ans);
	return 0;
}

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

using namespace std;

int main(){
	int l,count=0,min=0;
	cin >> l;
	string S;
	cin >> S;
	for(int i=0;i<l;i++){
		if(S[i]=='('){
			count++;
		}else{
			count--;
			if(min>count)min=count;
		}
	}
	for(int i=0;i>min;i--){
		S="("+S;
		count++;
	}
	while(count!=0){
		if(count>0){
			S+=")";
			count--;
		}else{
			S="("+S;
			count++;
		}
	}

	cout << S << endl;


	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16

ll n;
ll a[101010];

int main(){
	cin>>n;
  rep(i,n)cin>>a[i];
  map<ll,ll> cnt;
  set<ll> st;
  rep(i,n){
    cnt[a[i]]++;
    st.insert(a[i]);
  }
  if(st.size()>2){
    cout<<"No"<<endl;
    return 0;
  }
  if(st.size()==1){
    ll c1=*st.begin();
    if(c1==n-1||(1<=c1&&c1<=n/2)){
      cout<<"Yes"<<endl;
    }else cout<<"No"<<endl;
  }else{
    ll c1=*st.begin(),c2=*st.rbegin();
    if(c1+1!=c2){
      cout<<"No"<<endl;
      return 0;
    }
    if(c2>=cnt[c1]+1&&c2<=cnt[c1]+cnt[c2]/2){
      cout<<"Yes"<<endl;
    }else cout<<"No"<<endl;
  }
	return 0;
}


Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int a,b; cin >> a >> b;
  int c = max(a,b);
  if (a == b) COUT(a*2);
  else COUT(c+c-1);

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N,M,L,R;
int main(){
    cin>>N>>M;int max_min=N+1,min_max=0;for(int i=0;i<M;i++){cin>>L>>R;min_max=max(min_max,L);max_min=min(max_min,R);}
    int cnt=0;
    for(int i=1;i<=N;i++){cnt+=((i>=min_max)&&(i<=max_min)?1:0);}
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
import collections
n = int(input())
v = list(map(int, input().split()))
vo = [v[i] for i in range(n) if i%2 == 0]
ve = [v[i] for i in range(n) if i%2 == 1]
vo_dict = collections.Counter(vo)
ve_dict = collections.Counter(ve)
if vo_dict == ve_dict and len(vo_dict) == 1:
    ans = n//2
else:
    if vo_dict.most_common()[0][0] != ve_dict.most_common()[0][0]:
        ans = n - vo_dict.most_common()[0][1] - ve_dict.most_common()[0][1]
    else:
        ans = min(n - vo_dict.most_common()[0][1] - ve_dict.most_common(2)[1][1],
                  n - vo_dict.most_common(2)[1][1] - ve_dict.most_common()[0][1])
print(ans)

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

using namespace std;




int main() {
     
     set<int > s;
     int a;
     cin>>a;
     
     s.insert(a);
     vector<int> v;
     v.push_back(a);
     int i;
     for(i=1;;++i)
       {
           if(v[i-1]%2==0)
              { v.push_back(v[i-1]/2);
              
                if(s.find(v[i-1]/2)!=s.end())
                   break;
                   
                else
                    s.insert(v[i-1]/2);
                   
              }
              
           else
              { v.push_back(3*v[i-1]+1);
               
                if(s.find(3*v[i-1]+1)!=s.end())
                   break;
                   
                  else 
                    s.insert(3*v[i-1] + 1);   
                   
              }  
              
              
              
       }
       
       printf("%d",i+1);
     
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long int;
constexpr ll mod = 1e12;
int main()
{
	int n; cin >> n;
	ll ans = 0;
	for (int i = 1; i < n; ++i)ans += i;
	cout << ans;
	return 0;
}

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

int main(){
  string a,b;
  int i;
  cin >> a >> b;
  int x = stoi(a + b);
  for(i = 0; i < 1000; i++){
    if(i*i == x){
      cout << "Yes" << endl;
      return 0;
   }
  }

  cout << "No" << endl;

  return 0;
}

 

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

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

    if(N == 1) {
        cout << 2;
    }
    else {
        if(K == 1) {
            cout << N+1;
        }
        else if(2 <= K && K <= 4) {
            cout << 4 + K*(N-2);
        }
        else if(5 <= K && K <= 8) {
            if(N == 2) {
                cout << 4;
            }
            else {
                cout << 8 + K*(N-3);
            }
        }
        else {
            if(N == 2) {
                cout << 4;
            }
            else if(N == 3) {
                cout << 8;
            }
            else {
                cout << 16 + K*(N-4);
            }
        }
    }
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var K = int.Parse(Console.ReadLine());
            var items = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
            var A = items[0];
            var B = items[1];
            string answer = "NG";
            for (var i = A; i <= B; i++)
            {
                if (i % K == 0)
                {
                    answer = "OK";
                }
            }

            Console.WriteLine(answer);
        }
    }
}


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

using namespace std;

#define int long long

vector<int> ans;

int S(int x) {
        int ret = 0;
        while(x) {
                ret += x % 10;
                x /= 10;
        }
        return ret;
}


bool verify(int x, int y) {
        return x * S(y) < y * S(x);
}

void insert(int x) {
        while(verify(x, ans.back()))
                ans.pop_back();
        ans.push_back(x);
}

void init() {
        ans.push_back(1);
        for(int i = 2; i < 10000; i++) {
                insert(i);
        }
        for(int idx = 0, base = 10; idx < 12; idx++, base *= 10) {
                for(int i = 1000; i < 10000; i++)
                        insert(i * base + (base - 1));
        }
}

int32_t main() {
        cin.tie(0);
        cin.sync_with_stdio(0);
        init();

        int K;
        cin >> K;
        for(int i = 0; i < K; i++) {
                cout << ans[i] << '\n';
        }
}


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

int main(){
  int x,n;
  cin >> x >> n;
  vector<int> q(101,0);
  if(n == 0){
    cout << x << endl;
  }
  else{
    for(int i=0;i < n;i++){
      int y;
      cin >> y;
      q.at(y) = 1;
    }

    for(int i=0;i < 100;i++){
      int a = x + i;
      int b = x - i;
      if(b > 0){
        if(q.at(b) == 0){
          cout << b << endl;
          break;
        }
      }
      else{
        cout << b << endl;
        break;
      }
      if(a <= 100){
        if(q.at(a) == 0){
          cout << a << endl;
          break;
        }
      }
      else{
        cout << a << endl;
        break;
      }
    } 
  }
}
    

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << ""; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll h, w;
	string s;

	cin >> h >> w;

	vector<vector<string>> v(h);
	vector<vector<string>> vv;

	REP(i, h) {
		cin >> s;

		v[i].push_back(s);
	}

	REP(i, h) {
		REP(j, 2) {
			vv.push_back(v[i]);
		}
	}

	cout << vv << endl;
}

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

using namespace std;

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  auto a = min(A, K);
  auto b = min(B, K - a);
  auto c = min(C, K - a - b);
  cout << a - c << endl;
  return 0;
}


Measured memory_bytes: 3616