akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F         first
#define S          second
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
#define hell        1000000007
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 1e9
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 1e9+1;


using namespace std;
void solve();

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

int main(){
   fastIO();
    solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);

void solve(){

  int n;
  cin>>n;
  double p[n];
  forn(i,0,n)
  cin>>p[i];

  double dp[n+1][n+1];
  memset(dp,0.0,sizeof(dp));
  dp[0][0]=1;

  for(int i=1;i<=n;i++){
    dp[0][i]=(1.0-p[i-1])*dp[0][i-1];
    for(int j=1;j<=i;j++){
      dp[j][i]=p[i-1]*dp[j-1][i-1]+(1.0-p[i-1])*dp[j][i-1];
    }
  }
  double ans=0.0;
  for(int i=n/2+1;i<=n;i++)
  ans+=dp[i][n];

  cout<<fixed<<setprecision(10)<<ans;
}


///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll x,ll y){
  if(x==0)
  return y;
  else
  return gcd(y%x,x);
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1)%hell)*k%hell)%hell;
  else
  return ((pw(k,x/2)%hell)*(pw(k,x/2)%hell))%hell;
}

/*void sieve(){

  for(int i=2;i<=1000000;i++){
    if(prime[i]==true){
      for(int j=i*i;j<=1000000;j+=i)
      prime[j]=false;
    }
  }

}*/


Measured memory_bytes: 70656
import sys

readline = sys.stdin.readline


def main():
    N = int(readline())
    cnt = 0; leftB = 0; rightA = 0; same = 0
    for _ in range(N):
        s = readline()[:-1]
        for i in range(len(s)-1):
            subs = s[i:i+2]
            cnt += subs == 'AB'
        leftB += s[0] == 'B'
        rightA += s[-1] == 'A'
        same += s[0] == 'B' and s[-1] == 'A'
    
    if same == leftB == rightA:
        ans = cnt + max(min(N-1, same-1), 0)
    else:
        ans = cnt + min(N-1, leftB, rightA)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;

// tourist set
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << '\n'; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
// tourist set end

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; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<'\n'
#define p2(s, t) cout << (s) << " " << (t) << '\n'
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << '\n'
#define p_yes() p("Yes")
#define p_no() p("No")
#define SZ(x) ((int)(x).size())
#define SORT(A) sort(ALL(A))
#define RSORT(A) sort(ALL(A), greater<ll>())

void no(){p_no(); exit(0);}
void yes(){p_yes(); exit(0);}

const ll mod = 1e9 + 7;
const ll inf = 1e18;
const double PI = acos(-1);

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

    // input
    ll N; 
    cin >> N;
    string s; cin >> s;

    if(N%2==1) no();

    string a = s.substr(0, N/2);
    string b = s.substr(N/2, N/2);
    
    if(a==b){
      p_yes();
    }else{
      p_no();
    }
    
    return 0;
}

Measured memory_bytes: 256
//インクルード
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>

//型宣言
typedef long long ll;
typedef unsigned long long ull;
typedef std::string string;
typedef ull answerType;

//変数宣言
ll N;
ll M;
std::vector<string> Ai;
std::vector<string> Bi;
answerType answer;

//関数のプロトタイプ宣言
//入力の取得
void getInput();
//答えを求める
answerType calcAnswer();

//メイン関数
int main() {
	//入力の取得
	getInput();

	//答え
	answerType answer = calcAnswer();

	//答えの出力
	std::cout << answer << std::endl;

	//正常終了
	return EXIT_SUCCESS;
}

//入力の取得
void getInput() {
	std::cin >> N >> M;
}

//答えを求める
answerType calcAnswer() {
	ull temp = 0;
	ull N2 = N << 1;
	if(N2 <= M) {
		temp = N;
		M -= N2;
	} else {
		return M >> 1;
//		for(; N>=1 && M>=2; --N,----M,++temp) {
//		}
	}
	temp += M >> 2;
	return temp;
}


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

bool a(char c){
  if(c == 'A' || c == 'T' || c == 'G' || c == 'C') return true;
  return false;
}

int main(){
  int A, B, K;
  cin >> A >> B >> K;
  int N = min(A, B), counter = 0;
  while(N > 0){
    if(A % N == 0 && B % N == 0) counter++;
    if(counter == K) break;
    N--;
  }
  cout << N << endl;
  
}

Measured memory_bytes: 256
n,k = map(int,input().split())
s = list(input())

cnt = 0
temp1 = ""
btn = 0
ans = 0

for i in range(n):
    if i == 0:
        temp = s[i]
        continue
    if temp == s[i]:
        ans += 1
        continue
    else:
        temp = s[i]
        btn += 1
        if btn == 2:
            cnt += 1
            btn = 0

if cnt >= k:
    print(ans+2*k)
else:
    if btn == 1:
        print(ans+2*cnt+1)
    else:
        print(ans+2*cnt)

Measured memory_bytes: 4084
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M (1000000007)
#define N (100010)
struct data {
	int a,b;
} a[N];
int n,m,ans,f[N];
bool cmp(data o1,data o2) {
	return o1.b>o2.b;
}
int find(int x) {
	if (f[x]==x) return f[x];
	else return f[x]=find(f[x]);
}
int main() {
	scanf("%d%d",&n,&m);
	for (int i=1; i<=n; i++) scanf("%d%d",&a[i].a,&a[i].b);
	for (int i=1; i<=m; i++) f[i]=i;
	sort(a+1,a+1+n,cmp);
	for (int i=1; i<=n; i++) {
		if (a[i].a>m) continue;
		int fa=find(m-a[i].a+1);
		if (fa==0) continue;
		ans+=a[i].b;
		f[fa]=fa-1;
	}
	printf("%d",ans);
}


Measured memory_bytes: 1536
#include <stdio.h>

int N;
int h[100004];
int c[100004];

int getCost(int x, int y) {
	int c = x - y;
	return c < 0 ? c * -1 : c;
}

int cost(int i) {
	if (i >= N - 1)
		return 0;
	if (c[i] != -1)
		return c[i];
	int a = getCost(h[i], h[i+1]) + cost(i + 1);
	int b = i + 2 < N ? getCost(h[i], h[i+2]) + cost(i + 2) : a+1;
	c[i] = a < b ? a : b;
	return c[i];
}

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &h[i]);
		c[i] = -1;
	}

	printf("%d", cost(0));
}

Measured memory_bytes: 4096
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
ll a, b;
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for(ll i=2; i*i<=n; i++) {
    while(n % i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if(n != 1) ++res[n];
  return res;
}

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

  cin >> a >> b;

  ll gc = gcd(a, b);

  map<ll, ll> mp = prime_factor(gc);
  cout << mp.size() + 1 << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

	if (D == 25)
	{
		cout << "Christmas\n";
	}

	else if (D == 24)
	{
		cout << "Christmas Eve\n";
	}
	else if (D == 23)
	{
		cout << "Christmas Eve Eve\n";
	}
	else if (D == 22)
	{
		cout << "Christmas Eve Eve Eve\n";
	}



	return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010

int M;
int main()
{
    cin >> M;
    printf("%d\n", 24 + 24 - M);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
long long sum(long long n){return n*(n+1)/2;}
int main(){
  int n;
  scanf("%d",&n);
  long long ans;
  ans=sum(n)-sum(n/3)*3-sum(n/5)*5+sum(n/15)*15;
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 1724
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();

        if (S.charAt(0) == 'A') {
            System.out.println(judge(S) ? "AC" : "WA");
        } else {
            System.out.println("WA");
        }
    }

    private static boolean judge(String str) {
        for (char c : str.toCharArray()) {
            for (int ct = 'D'; ct <= 'Z'; ct++) {
                if (c == (char) ct) {
                    return false;
                }
            }
            if (c == 'B') {
                return false;
            }

        }
        str = str.substring(2);
        if (str.charAt(str.length() - 1) == 'C') {
            return false;
        } else if (str.contains("C")) {
            str = str.substring(0, str.length() - 1);
            return (str.indexOf("C") == str.lastIndexOf("C"));
        } else {
            return false;
        }
    }
}


Measured memory_bytes: 23764
n = int(input())
h = list(map(int, input().split()))
s = [0] * n

for i in range(1, n):
  if ((h[i-1] + s[i-1]) > h[i]):
    s[i] = (h[i-1] + s[i-1]) - h[i]

print(sum(s))

Measured memory_bytes: 32064
#include <stdio.h>
int main(void) {
	int n, a[200000];
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);

	int max = 0, keepi;
	for (int i = 0; i < n; i++) {
		if (max < a[i]) {
			max = a[i];
			keepi = i;
		}
	}

	int sec_max = 0;
	for (int i = 0; i < n; i++) {
		if (i != keepi) {
			if (sec_max < a[i])
				sec_max = a[i];
		}
	}

	for (int i = 0; i < n; i++) {
		if (a[i] == max)
			printf("%d\n", sec_max);
		else
			printf("%d\n", max);
	}
	return 0;
}

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

void main()
{
    bool n, w, s, e;
    foreach (c; readln.chomp) switch (c) {
        case 'N':
            n = true;
            break;
        case 'W':
            w = true;
            break;
        case 'S':
            s = true;
            break;
        case 'E':
            e = true;
            break;
        default:
    }
    writeln((n==s)&&(w==e) ? "Yes" : "No");
}

Measured memory_bytes: 256
let N = Int(readLine()!)!
var restaurants = [(num: Int, city: String, score: Int)]()
for i in 1...N {
    let input = readLine()!.characters.split(" ").map{String($0)}
    restaurants += [(num: i, city: input[0], score: Int(input[1])!)]
}
restaurants.sortInPlace{
  if $0.city == $1.city {
    return $0.score > $1.score
  }
  return $0.city < $1.city
}
for restaurant in restaurants {
    print(restaurant.num)
}

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

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int main(){
  int x, y;
  cin >> x >> y;

  if(y%2==1){
    cout << "No";
    return 0;
  }
  if(x*4 < y || x > y || x*2 > y){
    cout << "No";
    return 0;
  }

  int res = y/4;
  int num = y/2;

  if(num-res <=x){
    cout << "Yes";
    return 0;
  }
  cout << "No";

  return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ar array
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n, s = 0;
  cin >> n;
  vector<ll> a(100005, 0);
  for(int i=0; i<n; i++) {
    int x;
    cin >> x;
    a[x]++;
    s+=x;
  }
  int q;
  cin >> q;
  while(q--){
    int b, c;
    cin >> b >> c;
    s+=((c-b)*a[b]);
    a[c] +=a[b];
    a[b] = 0;
    cout << s << '\n';
  }
  return 0;
}


Measured memory_bytes: 3992
from math import cos,radians
a,b,h,m=map(int,input().split())
t=30*h
degr=min(abs(t-5.5*m),360-abs(t-5.5*m))
#print(degr)
c=a**2+b**2-2*a*b*cos(radians(degr))
print(c**0.5)
#print(c)

Measured memory_bytes: 9528
#include <iostream>

int a, b, c, d, e;

int kekka(int, int, int);
int main()
{
	std::cin >> a;
	std::cin >> b;

	d = 100000000000000 / a;
	std::cout << kekka(a,b,d) << std::endl;
	return 0;
}

int kekka(int a, int b, int d)
{
	if (( a == b) || (b == 1))
		{
			c = -1;
		}else if((a == 1) && (b != 2))
		{
			c = 2;
		}else if((a == 1) && (b == 2))
		{
			c = 3;
		}else if(( a < b) && ( b % a != 0))
		{
			c = a * 2;
		} else {
		for(int i = 2 ; i <= d; i++)
		{
			e =  a * i; 
			if((e % a == 0) && (e % b != 0))
			{
				c = e;
				break;
			}
			else{
				c = -1;
			}
		}
	}
	return c;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <set>
#include <cstdio>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <algorithm>
#include <limits>
#include <map>

using namespace std;
typedef long long ll;

char s[110];
int n;
int dd[5];
char u[] = "01+-*()";
bool err;
int ec;

int expr(char **begin);

void erce(int i) {
    err |= (i  < 0 || 1024 <= i);
}

int numb(char **begin) {
    int r = 0;
    if (!isdigit(**begin)) err = true;
    while (isdigit(**begin)) {
        r *= 2;
        r += **begin - '0';
        *begin += 1;
    }
    erce(r);
    return r;
}

int fact(char **begin) {
    if (**begin == '(') {
        *begin += 1;
        int ec2 = ec;
        int r = expr(begin);
        if (ec2 == ec) err = true;
        ec = ec2;
        if (**begin != ')') err = true;
        *begin += 1;
        erce(r);
        return r;
    } else {
        return numb(begin);
    }
}

int term(char **begin) {
    int r = fact(begin);
    while (true) {
        if (**begin == '*') {
            ec++;
            *begin += 1;
            r *= fact(begin);
            erce(r);
        } else {
            break;
        }
    }
    return r;
}

int expr(char **begin) {
    int r = term(begin);
    while (true) {
        if (**begin == '+') {
            ec++;
            *begin += 1;
            r += term(begin);
            erce(r);
        } else if (**begin == '-') {
            ec++;
            *begin += 1;
            r -= term(begin);
            erce(r);
        } else {
            break;
        }
    }
    return r;
}


int main() {
    string ss;
    cin >> ss;
    n = ss.size();
    int cc = 1;
    int c = 0;
    for (int i = 0; i < n; i++) {
        s[i] = ss[i];
        if (s[i] == '.') {
            dd[c] = i;
            c++;
            cc *= 7;
        }
    }
    s[n] = '$';
    int res = -1;
    for (int i = 0; i < cc; i++) {
        int ii = i;
        for (int j = 0; j < c; j++) {
            s[dd[j]] = u[ii%7];
            ii /= 7;
        }
        err = false;
        ec = 0;
        char *p = s;
        int r = expr(&p);
        if (*p != '$') err = true; 
        if (!err) res = max(res, r);
        //printf("%10s %d %d\n", s, r, err);
    }
    cout << res << endl;
    return 0;
}

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

typedef int weight;
typedef vector<int> vec;
typedef vector<vec> matrix;
const int inf = (1<<29);
weight OPT[(1<<7)][200];
weight minimum_steiner_tree(const vector<int>& T, const matrix &g) {
  memset( OPT,0,sizeof( OPT ) );
  const int n = g.size();
  const int numT = T.size();
  if (numT <= 1) return 0;

  matrix d(g); // all-pair shortest

  for (int k = 0; k < n; ++k)
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j)
        d[i][j] = min( d[i][j], d[i][k] + d[k][j] );
  
  for (int S = 0; S < (1 << numT); ++S)
    for (int x = 0; x < n; ++x)
      OPT[S][x] = inf;

  for (int p = 0; p < numT; ++p) // trivial case
    for (int q = 0; q < n; ++q)
      OPT[1 << p][q] = d[T[p]][q];

  for (int S = 1; S < (1 << numT); ++S) { // DP step
    if (!(S & (S-1))) continue;
    for (int p = 0; p < n; ++p)
      for (int E = 0; E < S; ++E)
        if ((E | S) == S)
          OPT[S][p] = min( OPT[S][p], OPT[E][p] + OPT[S-E][p] );
    for (int p = 0; p < n; ++p)
      for (int q = 0; q < n; ++q)
        OPT[S][p] = min( OPT[S][p], OPT[S][q] + d[p][q] );
  }
  weight ans = inf;
  for (int S = 0; S < (1 << numT); ++S)
    for (int q = 0; q < n; ++q)
      ans = min(ans, OPT[S][q] + OPT[((1 << numT)-1)-S][q]);
  return ans;
}

int main(){
  int H,W;
  while( cin >> H >> W && (H||W) ){
    vector<int> T;
    matrix G;
    G.resize( H*W, vec( H*W, inf ) );
    int dx[]={1,0,-1,0};
    int dy[]={0,1,0,-1};
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
        G[ i*W + j ][ i*W + j] = 0;
        int c; cin >> c;
        if( c == 1 ) T.push_back( i*W+j );
        for(int k=0;k<4;k++){
          int nx = j + dx[k] , ny = i + dy[k];
          if( nx < 0 || ny < 0 || nx >= W || ny >= H ) continue;
          G[ i*W + j ][ ny*W + nx ] = 1;
        }
      }
    }
    cout << H*W - 1 - minimum_steiner_tree( T, G ) << endl;
  }
}

Measured memory_bytes: 3292
/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.

*/
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;
typedef long long ll;

int mod = 1000000007;
ll dp[100005];;

ll gcd(long long a,long long b){

  if(b == 0)
    return a;
  else return gcd(b,a%b);
}

bool compare(pair<int,int>p1, pair<int,int>p2){

  return p1.second > p2.second;
 }

 // sorting the map when the first is string ans second is the integer
 bool sortbyval(pair<string,int>a, pair<string,int>b){
   return a.second < b.second;
 }

 int ani[4] = {4,6,9,11};

int main(){

 long long x,y;
 cin>>x>>y;

  vector<int>vec(13);
 vec = {0,1,3,1,2,1,2,1,1,2,1,2,1};


  if(vec.at(x) == vec.at(y))
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;

 return 0;
}

Measured memory_bytes: 3592
N,M=map(int,input().split())
if N%2==1:
    for i in range(1,M+1):
        a,b=i,N-i
        print(a,b)
else:
    for i in range(1,M+1):
        a,b=i,N-i
        if b-a<=N//2:
            a+=1
        print(a,b)

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

int main() {

  long long int n;
  cin >> n;

  long long int ans = 100;

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

    if ( ( n % i ) != 0 ) continue;
    long long int k = n / i;
    long long int cnt = 0;
    while( k > 0 ) {
      k /= 10;
      cnt++;
    }
    ans = min( ans, cnt );

  }

  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

H, W, M = map(int, input().split())

rows = [0] * (H + 1)
cols = [0] * (W + 1)

from collections import defaultdict
ng_cols = defaultdict(set)

for _ in range(M):
    h, w = map(int, input().split())
    rows[h] += 1
    cols[w] += 1
    ng_cols[h].add(w)

max_of_rows = max(rows)
max_of_cols = max(cols)
max_rows_index = set()
max_cols_index = set()
for i in range(H + 1):
    if rows[i] == max_of_rows:
        max_rows_index.add(i)
for i in range(W + 1):
    if cols[i] == max_of_cols:
        max_cols_index.add(i)
flag = 0
for i in max_rows_index:
    cnt = 0
    for j in ng_cols[i]:
        if j in max_cols_index:
            cnt += 1
    if cnt < len(max_cols_index):
        flag += 1
        break
        
print(max_of_rows + max_of_cols - 1 + flag)








Measured memory_bytes: 215264
IDENTIFICATION DIVISION.
PROGRAM-ID. 139B.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP  PIC X(10).
01 A    PIC 9(2).
01 B    PIC 9(2).
01 I    PIC 9(2).
01 OUT  PIC ZZ9.
*>  
PROCEDURE DIVISION.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ' '
      INTO A B.
*>
  IF (B = 1)
    MOVE 0 TO I
  ELSE
    PERFORM VARYING I FROM 1 BY 1 
      UNTIL (A - 1) * I + 1 >= B
    END-PERFORM
  END-IF.
*>
  MOVE I TO OUT.
  DISPLAY OUT.
*>
  STOP RUN.


Measured memory_bytes: 384
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        int m,f,r;
        Scanner s = new Scanner(System.in);
        while(true){
            m = s.nextInt();
            f = s.nextInt();
            r = s.nextInt();
            if(m==-1&&f==-1&&r==-1)break;
            if(m==-1||f==-1)System.out.println("F");
            else if(m+f>=80)System.out.println("A");
            else if(m+f>=65)System.out.println("B");
            else if(m+f>=50)System.out.println("C");
            else if(m+f>=30){
                if(r>=50)System.out.println("C");
                else System.out.println("D");
            }
            else System.out.println("F");
 
 
        }
    }
}


Measured memory_bytes: 26144
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        init();
        String stringN = next();
        int K = nextInt();
        int length = stringN.length();
        if (K > length) {
            System.out.println(0);
            return;
        }
        long ans = 0;
        for (int n = K; n < length; n++) {
            int mul = (int) Math.pow(9, K - 1);
            ans += 9 * choose(n - 1, K - 1) * mul;
        }
        int rem = K - 1;
        for (int i = 1; i < 10; i++) {
            if (i > stringN.charAt(0) - '0') break;
            boolean less = i < stringN.charAt(0) - '0';
            if (rem == 0) ans++;
            else if (rem == 1) {
                for (int j = 1; j < length; j++) {
                    int jUp = 9;
                    if (!less) jUp = stringN.charAt(j) - '0';
                    ans += jUp;
                    less = less || (stringN.charAt(j) - '0' > 0);
                }
            } else {
                for (int j = 1; j < length; j++) {
                    int jUp = 9;
                    if (!less) jUp = stringN.charAt(j) - '0';
                    for (int jj = 1; jj <= jUp; jj++) {
                        boolean nowLess = less || jj < stringN.charAt(j) - '0';
                        for (int k = j + 1; k < length; k++) {
                            int kUp = 9;
                            if (!nowLess) kUp = stringN.charAt(k) - '0';
                            ans += kUp;
                            nowLess = nowLess || (stringN.charAt(k) - '0' > 0);
                        }
                    }
                    less = less || (stringN.charAt(j) - '0' > 0);
                    // 117857916
                }
            }
        }

        System.out.println(ans);
    }

    private static long choose(int n, int k) {
        long ans = 1;
        for (int i = 0; i < k; i++) {
            ans *= (n - i);
        }
        long fac = 1;
        for (int i = 1; i <= k; i++) {
            fac *= i;
        }
        ans /= fac;
        return ans;
    }

    //Input Reader
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    private static void init() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    private static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
}

Measured memory_bytes: 22100
n = int(input())
h = list(map(int, input().split()))
dp = [0]
dp.append(abs(h[1]-h[0]))
if n > 2:
    for i in range(2,n):
        dp.append(min(abs(h[i]-h[i-2])+dp[i-2],abs(h[i]-h[i-1])+dp[i-1]))
print(dp[-1])

Measured memory_bytes: 13928
data class Point(val x: Int, val y: Int, val a: Int)

fun main(args: Array<String>) {
    val (w, h, n) = readLine()?.split(" ")?.map { it.toInt() } ?: return
    val points: List<Point> = (0 until n).map {
        val (x, y, a) = readLine()?.split(" ")?.map { it.toInt() }!!
        Point(x, y, a)
    }

    var startX = 0
    var endX = w
    var startY = 0
    var endY = h

    for (point in points) {
        when (point.a) {
            1 -> {
                if (startX < point.x) {
                    startX = point.x
                }
            }
            2 -> {
                if (endX > point.x) {
                    endX = point.x
                }
            }
            3 -> {
                if (startY < point.y) {
                    startY = point.y
                }
            }
            4 -> {
                if (endY > point.y) {
                    endY = point.y
                }
            }
        }
    }
    if (startX >= endX || startY >= endY) {
        println(0)
    } else {
        println((endX - startX) * (endY - startY))
    }
}

Measured memory_bytes: 37896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
     int n,x=0;
     cin>>n;
     int a[n+2];
     for(int i=0;i<n;i++){
        cin>>a[i];
        x = x ^ a[i];
     }
     for(int i=0;i<n;i++){
        a[i]^=x;
        cout<<a[i]<<" ";
     }
}


Measured memory_bytes: 4440
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<vector<int>> array(n,vector<int>(3));
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<3;j++)
    cin>>array[i][j];
  }
  vector<vector<int>> dp(n,vector<int> (3,0));
  dp[0][0]=array[0][0];dp[0][1]=array[0][1];dp[0][2]=array[0][2];
  for(int i=1;i<n;i++)
  {
      for(int j=0;j<3;j++)
      {
        for(int k=0;k<3;k++)
        {
            if(k==j)
            continue;
            else
            dp[i][j]=max(dp[i-1][k]+array[i][j],dp[i][j]);
        }
      }
  }
  cout<<max(dp[n-1][2],max(dp[n-1][1],dp[n-1][0]));
 return 0;
}

Measured memory_bytes: 11136
import math
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

indp = 1
indq = 1

# pの辞書式順列番号
for i in range(n):
  c = 1
  for j in p[:i]:
    if (j < p[i]):
      c += 1
  indp += math.factorial((n-1)-i) * (p[i]-c)

# qの辞書式順列番号
for i in range(n):
  c = 1
  for j in q[:i]:
    if (j < q[i]):
      c += 1
  indq += math.factorial((n-1)-i) * (q[i]-c)

print(abs(indp-indq))

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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



int main()
{
	ll N, M;
	cin >> N >> M;
	vector<ll> A(N);
	REP(i, N)cin >> A[i];
	sort(A.begin(), A.end());

	vector<pair<ll, ll>> cb(M);
	REP(i, M)cin >> cb[i].second >> cb[i].first;
	sort(cb.begin(), cb.end(), greater<pair<ll, ll>>());

	int idx = 0;
	for (auto p : cb) {
		REP(i, p.second) {
			if (idx == N)goto end;
			if (p.first > A[idx]) {
				A[idx] = p.first;
				idx++;
			}
			else {
				goto end;
			}
		}
	}
end:;
	cout << accumulate(A.begin(), A.end(), 0ll) << endl;
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 1000000007
#define M 2e5
using namespace std;
using ll = long long;
using ldb = long double;

long long mypow(long long k, long long n) {
	long long temp = 1;

	k = k % DIV;
	while (n) {
		if (n % 2) temp = temp * k % DIV;
		k = k * k % DIV;
		n = n / 2;
	}
	return temp % DIV;
}

ll modmul(ll a, ll b) {
	ll res = (a % DIV) * (b % DIV);
	return res % DIV;
}

ll modeadd(ll a, ll b) {
	ll res = (a % DIV) + (b % DIV);
	return res % DIV;
}
int main() {
	int n; cin >> n;
	ll A = 0, B = 0;
	map<int, pair<int, int>> mp;
	for (int i = 0; i <= n; i++) {
		int a; cin >> a;
		if (mp[a].first == 0) mp[a].first++, mp[a].second = i;
		else A = mp[a].second, B = n - i;
	}

	vector<ll> f(M + 1), invf(M + 1);
	f[0] = 1, invf[0] = 1;
	for (ll i = 1; i <= M; i++) {
		f[i] = (f[i - 1] * i) % DIV;
		invf[i] = mypow(f[i], DIV - 2);
	}

	for (int k = 1; k <= n + 1; k++) {
		ll temp1 = modmul(f[n + 1], modmul(invf[k], invf[n + 1 - k]));
		ll temp2 = 0;
		if (A + B + 1 - k < 0)temp2 = 0;
		else temp2 = modmul(f[A + B], modmul(invf[k - 1], invf[A + B + 1 - k]));
		cout << (temp1 - temp2 + DIV) % DIV << endl;
		
	}

}

Measured memory_bytes: 12700
import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
def ddprint(x):
  if DBG:
    print(x)

x,a = inm()
if x<a:
    print(0)
else:
    print(10)


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

using namespace std;

const int MAX_N = 3000, MOD = 1000000007;

int n;

bool isPrime[MAX_N + 1];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie();
    cout.tie();

    cin >> n;

    for (int i = 2; i <= n; i++) {
        isPrime[i] = true;
    }

    for (int i = 2; i * i <= n; i++) {
        if (isPrime[i]) {
            for (int j = i * i; j <= n; j += i) {
                isPrime[j] = false;
            }
        }
    }

    long long ans = 1;
    for (int i = 2; i <= n; i++) {
        if (isPrime[i]) {
            int anst = 1;
            for (int x = i; x <= n; x *= i) {
                anst += n / x;
            }

            ans *= anst;
            ans %= MOD;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <bitset>
#include <queue>
#include <iostream>

using namespace std;

#define MAXN 510
#define INF 0x3f3f3f3f
typedef long long LL;

int main()
{
    int i, n, a = 0, b = INF, cnt[2] = {};
    int ans[2] = {};
    char s[MAXN];
    scanf("%d %s", &n, s);
    for(i = 0; i < n; ++i){
        if(s[i] == '(') ++cnt[0], ++a;
        else ++cnt[1], --a;
        b = min(a, b);
    }
    if(b < 0){
        ans[0] -= b;
        a -= b;
    }
    if(a > 0){
        ans[1] += a;
    }
    else ans[0] -= a;

    for(i = 1; i <= ans[0]; ++i)
        printf("(");
    printf("%s", s);
    for(i = 1; i <= ans[1]; ++i)
        printf(")");

    return 0;
}


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

typedef long long int ll;
using namespace std;

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

	map<ll,int> mp;

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

	if(mp.size() > 3) {
		cout<<"No"; return 0;
	}

	auto it = mp.begin();

	if(mp.size() == 1){
		
		if(it->first == 0){
			cout<<"Yes"; 
		}
		else cout<<"No";
	}

	if(mp.size() == 2){
		if(it->first == 0 and n%3==0){
			int f1 = it->second;
			it++;
			int x = it->first;
			int f2 = it->second;
			if(f1 == n/3 and f2 == (2*n)/3) cout<<"Yes"; else cout<<"No"; return 0;

		}
		else cout<<"No"; return 0;
	}

	if(mp.size() == 3){
		int ans=0;
		ans ^= it->first;
		int f1=it->second; it++;
		ans ^= it->first;
		int f2=it->second; it++;
		ans ^= it->first;
		int f3=it->second; it++;

		if(f1==n/3 and f2==n/3 and f3==n/3 and n%3==0 and ans==0) cout<<"Yes"; else cout<<"No"; return 0;
	}
}
















Measured memory_bytes: 5120
#include<iostream>
#include<vector>

using namespace std;

int main(){

    int h, w;
    cin >> h >> w;
    int c[10][10];
    int tmp, ans = 0;

    for(int i=0; i<=9; i++)
        for(int j=0;j<=9;j++)
            cin >> c[i][j];

    for(int i=0; i<=9; i++)
        for(int j=0;j<=9;j++)
            for(int k=0;k<=9;k++)
                c[j][k] = min(c[j][k], c[j][i]+c[i][k]);
    
    for(int i=0; i<h; i++)
        for(int j=0;j<w;j++){
            cin >> tmp;
            ans += c[tmp][1];
        }
    cout << ans << endl;
    return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	double N=in();

	out(2.0*N*4.0*atan(1));

	return 0;
}


Measured memory_bytes: 3808
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
using namespace std;


int main() {
    int n,q;
    int s,t,x;
    int d;
    cin>>n>>q;
    vector<pair<pair<int,int>,int>> p;
    for(int i=0;i<n;++i){
        cin>>s>>t>>x;
        p.push_back({{s-x,1},x});
        p.push_back({{t-x,-1},x});
    }
    vector<pair<int,int>> person;
    for(int i=0;i<q;++i){
        cin>>d;
        person.push_back({d,i});
    }
    sort(person.begin(),person.end());
    sort(p.begin(),p.end());
    reverse(p.begin(),p.end());
    reverse(person.begin(),person.end());
    vector<int> ans(q,-1);
    set<int> S;
    while(!p.empty()&&!person.empty()){
        while(!person.empty()&&person.back().first<p.back().first.first){
            if(!S.empty())ans[person.back().second]=*S.begin();
            person.pop_back();
        }
        int T=p.back().first.first;
        while(!p.empty()&&p.back().first.first==T){
            if(p.back().first.second==1){
                S.insert(p.back().second);
            }else{
                S.erase(p.back().second);
            }
            p.pop_back();
        }
    }
    while(!person.empty()){
        if(!S.empty())ans[person.back().second]=*S.begin();
        person.pop_back();
    }
    for(int u:ans)cout<<u<<endl;
    return 0;
}


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

#ifndef ONLINE_JUDGE
    #define gc getchar
    #define pc putchar
#else
    #define gc getchar_unlocked
    #define pc putchar_unlocked
#endif

using namespace std;

#define vi vector<int>
#define si set<int>
#define vs vector<string>
#define pii pair<int,int>
#define vpi vector<pii>
#define pri priority_queue<int>
#define rev_pri priority_queue<int,vector<int>,greater<int> >
#define mpi map<int,int>
#define i64 long long int
#define endl '\n'
#define pi acos(-1)
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf INT_MAX/2
#define infll LLONG_MAX/3
#define For(i,n) for(int i=0;i<n;i++)
#define Fre(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pfn(n) printf("%d\n", n)
#define pfs(n) printf("%d ", n)
#define eps 1e-8
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define READ freopen("in.txt", "r", stdin)
#define WRITE freopen("out.txt", "w", stdout)
#define sz size()
#define dbg(i) printf("yo %d\n", i)
#define foreach(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define sqr(a) (a) * (a)
#define clr clear()
#define CASE(a) printf("Case %d: ",a)

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


i64 gcd(i64 a,i64 b){if(!b)return a;return gcd(b,a%b);}

//inline void fastRead(int *a){register char c=0;while(c<33)c=gc();*a=0;while(c>33){*a=*a*10+c-'0';c=gc();}}

//inline void fastWrite(int a){char snum[20];int i=0;do{snum[i++]=a%10+48;a=a/10;}while(a!=0);i=i-1;while(i>=0)pc(snum[i--]);pc('\n');}

//i64 bigmod(i64 num,i64 n){if(n==0)return 1;i64 x=bigmod(num,n/2);x=x*x%mod;if(n%2==1)x=x*num%mod;return x;}

//i64 modinverse(i64 num){return bigmod(num,mod-2)%mod;}

//i64 po(i64 a,i64 b){i64 ans=1;while(b--)ans *= a;return ans;}

//i64 ncr(i64 n,i64 r){if(n==r)return 1;if(r==1)return n;if(dp[n][r]!=-1)return dp[n][r];return dp[n][r]=ncr(n-1,r)+ncr(n-1,r-1);}


// bit manipulations

//bool checkbit(int mask,int bit){return mask & (1<<bit);}

//int setbit(int mask,int bit){ return mask  (1<<bit) ; }

//int clearbit(int mask,int bit){return mask & ~(1<<bit);}

//int togglebit(int mask,int bit){return mask ^ (1<<bit);}


#define mxn 100005

vpi v[mxn];
i64 dis[mxn];

void dfs(int s,i64 lvl)
{
        dis[s] = lvl;

        For(i,v[s].sz)
        {
                int vv = v[s][i].ff;
                int ww = v[s][i].ss;
                if(dis[vv]==-1)
                        dfs(vv,lvl+ww);
        }
}

int main()
{

        int n , a , b , c , q, k;
        mem(dis,-1);
        sf(n);

        For(i,n-1)
        {
                sfff(a,b,c);
                v[a].pb(mp(b,c));
                v[b].pb(mp(a,c));
        }

        sff(q,k);

        dfs(k,0);

//        Fre(i,1,n+1)
//                cout << i << " " << dis[i] << endl;
        while(q--)
        {
                sff(a,b);
                cout << dis[a] + dis[b] << endl;
        }





        return 0;
}



Measured memory_bytes: 12800
import java.util.*;

class Animal
{
    String name;
    String genus;
    int region;

    public Animal(String name, String genus, int region)
    {
        this.name = name;
        this.genus = genus;
        this.region = region;
    }

    public int getRegion()
    {
        return this.region;
    }

    public String getGenus()
    {
        return this.genus;
    }

    public String getName()
    {
        return this.name;
    }
}

class Human extends Animal
{
    String sex;
    String bloodGroup;

    public Human(String sex, String bloodGroup)
    {
        super("HS", "homo", 1);
        this.sex = sex;
        this.bloodGroup = bloodGroup;
    }

    public String getSex()
    {
        return sex;
    }

    public String getBloodGroup()
    {
        return bloodGroup;
    }
}

public class Main
{

    public static Scanner in = new Scanner(System.in);

    public void print(int[] a)
    {
        for (int i = 0; i <a.length-1 ; i++)
        {
            System.out.print(a[i]+" ");
        }
        System.out.println(a[a.length-1]);
    }

    public int[] insert(int[] a)
    {

        for (int i = 0; i <a.length ; i++)
        {
            int key=a[i];
            int j=i-1;

            while (j>=0 && a[j]>key)
            {
                a[j+1] = a[j];
                j--;
            }
            a[j+1] = key;
            new Main().print(a);
        }
        return a;

    }

    public int gcd(int a, int b)
    {
        if(b==0)
        {
            return a;
        }
        else
        {
            return gcd(b, a%b);
        }
    }

    public void go()
    {
        int N=in.nextInt();
        int[] box = new int[N];
        for (int i = 0; i <box.length ; i++)
        {
            box[i] = in.nextInt();
        }

        new Main().insert(box);

    }

    public static void main(String[] args)
    {
        new Main().go();


    }
}

Measured memory_bytes: 33008
#include <bits/stdc++.h> 
using namespace std ; 
#define ll long long int 
#define pb push_back
#define ff first 
#define dobara(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define ss second 
#define S(x) scanf("%d",&x) 
#define SL(x) scanf("%lld",&x)
#define M 1000000007
#define sz(x) (int)x.size()
#define all(a) (a).begin(),(a).end()
int r , c , n ; 

bool valid(int x , int y){
	if(x <= 0 || x > r || y <= 0 || y > c){
		return 0 ; 
	}
	return 1 ; 
}

int main(){
	int sr , sc ; 
    string s , t ; 
    cin>>r>>c>>n>>sr>>sc>>s>>t ;
    int flg = 0 ; 
    int x = sr , y = sc ; 
    for(int i=0;i<n;i++){
    	
    	
    	
    		if(s[i] == 'R'){
    			y = y + 1 ; 
    			if(!valid(x,y)){
    				flg = 1 ;
    				break ;  
    			}
    		}
    		if(t[i] == 'L'){
    			if(valid(x,y-1)){
    				y = y-1 ; 
    			}
    		}
    }

    if(flg){
    	cout<<"NO\n" ;
    	return 0 ; 
    }

    x = sr , y = sc ; 

    for(int i=0;i<n;i++){
    	
    	
    	
    		if(s[i] == 'L'){
    			y = y - 1 ; 
    			if(!valid(x,y)){
    				flg = 1 ;
    				break ;  
    			}
    		}
    		if(t[i] == 'R'){
    			if(valid(x,y+1)){
    				y = y+1 ; 
    			}
    		}
    	
    }

    if(flg){
    	cout<<"NO\n" ; 
    	return 0 ; 
    } 
    
    x = sr , y = sc ; 
    for(int i=0;i<n;i++){
    	
    	
    	
    		if(s[i] == 'D'){
    			x = x + 1 ; 
    			if(!valid(x,y)){
    				flg = 1 ;
    				break ;  
    			}
    		}
    		if(t[i] == 'U'){
    			if(valid(x-1,y)){
    				x = x-1 ; 
    			}
    		}
    	
    }

    if(flg){
    	cout<<"NO\n" ; 
    	return 0 ; 
    }

    x = sr , y = sc ; 
    for(int i=0;i<n;i++){
    	
    
    		if(s[i] == 'U'){
    			x = x - 1 ; 
    			if(!valid(x,y)){
    				flg = 1 ;
    				break ;  
    			}
    		}
    		if(t[i] == 'D'){
    			if(valid(x+1,y)){
    				x = x+1 ; 
    			}
    		}
    	
    }

    if(flg){
    	cout<<"NO\n" ; 
    	return 0 ; 
    }
    cout<<"YES\n" ; 
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, a;
  cin >> n;
  vector<int> vec(100010, 0);
  for (int i = 0; i < n; i++) {
    cin >> a;
    ++(vec[a]);
    ++(vec[a+1]);
    ++(vec[a+2]);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  cout << vec[0] << '\n';
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define forn(b) for(int i = 0; i < b; i++)
#define rforn(b) for(int i = b - 1 ;i >= 0; i--)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
const ll mod = (ll)1e9 + 7;
    
int main(){
    speed;
    int n1, n2; cin >> n1 >> n2;
    int k = n2 - (2 * n1);
    if(k < 0) cout << "No";
    else {
        if(k % 2 == 0) {
            int x1 = k / 2;
            int y1 = n1 - x1;
            if(x1 >= 0 && y1 >= 0) {
                cout << "Yes";
            }
            else {
                cout << "No";
            }
        }
        else {
            cout << "No";
        }
    }
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x) // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    vector<ll> c(2, 0);
    for (auto i : s)
    {
        c[i - '0']++;
    }
    cout << s.size() - abs(c[0] - c[1]) << endl;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace codeTester.contest190720
{
    class ProblemC
    {
        static int n = 0;
        static List<long> values = new List<long>();
        static List<long> answer = new List<long>();

        public static void Main(string[] args)
        {
            Input();
            Logic();
            Output();
        }

        static void Input()
        {
            n = int.Parse(Console.ReadLine());
            values = ReadIndentationSeparatedValues(n);
        }

        public static List<long> ReadSpaceSeparatedValues()
        {
            List<long> values = new List<long>();
            string[] inputs = Console.ReadLine().Split(' ');
            foreach (string input in inputs)
            {
                values.Add(long.Parse(input));
            }

            return values;
        }

        public static List<long> ReadIndentationSeparatedValues(int num)
        {
            List<long> values = new List<long>();
            for (int i = 0; i < num; i++)
            {
                string input = Console.ReadLine();
                values.Add(long.Parse(input));
            }

            return values;
        }

        static void Logic()
        {
            // 最大値を除外したものを考えれば良い。
            List<long> sortedA = values.OrderByDescending(v => v).ToList();
            long max = sortedA[0];
            long semimax = sortedA[1];
            foreach(long v in values)
            {
                answer.Add(v == max ? semimax : max);
            }
        }

        static void Output()
        {
            foreach(long a in answer)
            {
                Console.WriteLine(a.ToString());

            }
        }

        static void DebugPrint(string msg)
        {
            // 提出時に消す
            // Console.WriteLine(msg);
        }
    }
}


Measured memory_bytes: 30812