akhauriyash/Code-Regression huggingface dataset:
use proconio::input;
use std::collections::HashSet;

fn main() {
    input! {
        a: usize,
        b: usize,
    }
    let set_a = prime_factorize(a); 
    let set_b = prime_factorize(b); 
    let intersection = set_a.intersection(&set_b);

    let mut count = 1;
    for _ in intersection {
        //println!("{}", i);
        count+=1;
    }
    println!("{}", count);
}

fn enum_divisiors(n: usize) -> HashSet<usize> {
    let mut res = HashSet::new();
    let mut i = 1;
    while i * i <= n {
        if n % i == 0 {
            res.insert(i);
            if n/i != i {
                res.insert(n/i);
            }
        }
        i+=1;
    }
    return res;
}

fn prime_factorize(mut n: usize) -> HashSet<usize> {
    let mut res = HashSet::new();
    let mut a = 2;
    while a * a <= n {
        if n % a != 0 {
            a+=1;
            continue;
        }
        let mut _ex = 0;
        while n % a == 0 {
            _ex+=1;
            n/=a;
        }
        res.insert(a);
        a+=1;
    }

    if n != 1 {
        res.insert(n);
    }
    return res;
}

Measured memory_bytes: 2192
h, w = map(int, input().split())
S = [input() for _ in range(h)]
dp = [[0]*w for _ in range(h)]
for i in range(h):
  for j in range(w):
    if i == 0 and j == 0:
      if S[0][0] == "#":
        dp[0][0] = 1
      continue
    if i:
      u = dp[i-1][j]
      if S[i-1][j] == "." and S[i][j] == "#":
        u += 1
    else:
      u = float("inf")
    if j:
      v = dp[i][j-1]
      if S[i][j-1] == "." and S[i][j] == "#":
        v += 1
    else:
      v = float("inf")
    dp[i][j] = min(u, v)
print(dp[-1][-1])

Measured memory_bytes: 3064
Module Main

    Sub Main()

        Dim arr() As String
        Dim a As Integer = 0
        Dim b As Integer = 0

        '入力値取得
        arr = Split(Console.ReadLine())
        a = Integer.Parse(arr(0))
        b = Integer.Parse(arr(1))

        '処理結果出力
        Console.WriteLine(IIf(a * b Mod 2 = 0, "Even", "Odd"))

    End Sub

End Module

Measured memory_bytes: 13408
/*
         ██╗ ██████╗ ██╗███╗   ██╗    ██╗   ██╗███████╗
         ██║██╔═══██╗██║████╗  ██║    ██║   ██║██╔════╝
         ██║██║   ██║██║██╔██╗ ██║    ██║   ██║███████╗
    ██   ██║██║   ██║██║██║╚██╗██║    ██║   ██║╚════██║
    ╚█████╔╝╚██████╔╝██║██║ ╚████║    ╚██████╔╝███████║
     ╚════╝  ╚═════╝ ╚═╝╚═╝  ╚═══╝     ╚═════╝ ╚══════╝
*/
//password:+BdCHpO8dQvpo5fnV3/u
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn = 5e5 + 5;
const int inf = 0x3f3f3f3f;
priority_queue<ll>pq;

int main() {
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        ll x;
        cin>>x;
        pq.push(x);
    }
    while(m--)
    {
        ll r=pq.top();
        pq.pop();
        r/=2;
        pq.push(r);
    }
    ll ans=0;
    while(pq.size()) ans+=pq.top(),pq.pop();
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1400
//auto 関数名 = [(&:ラムダ外の引数をとる時))](引数の型1 引数名1, 引数の型2, 引数名2, ...) { 関数の処理 }; //inside main() define function. take care of };
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }
// sort(配列変数.begin(), 配列変数.end());
// do {
//   // 順列に対する処理
// } while (next_permutation(配列変数.begin(), 配列変数.end()));
//const double PI = acos(-1); M_PI
// cout << fixed << setprecision(10);
#include <bits/stdc++.h>
#include <regex>
using namespace std;
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end() //sort(all(vec)); ,reverse(all(vec));etc
int main(){
string s;
cin>>s;
if(s=="RRR"){
  cout<<3<<endl;
  return 0;
}
if(s=="RRS"||s=="SRR"){
  cout<<2<<endl;
  return 0;
}
if(s=="RSR"||s=="RSS"||s=="SRS"||s=="SSR"){
  cout<<1<<endl;
  return 0;
}
if(s=="SSS"){
  cout<<0<<endl;
  return 0;
}

}


Measured memory_bytes: 3604
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }

int main() {
   int N, M;
   cin >> N >> M;
   int A[N];
   for (int i = 0; i < N; i++) cin >> A[i];
   sort(A, A + N);
   
   int B, C;
   int CMax = 0;
   vector<int> rest;
   vector<ipair> BC;
   for (int i = 0; i < M; i++) {
      cin >> B >> C;
      BC.push_back(ipair(B, C));
      CMax = max(C, CMax);
   }
   sort(BC.begin(), BC.end(), morePair);

   int cnt0 = 0;
   for (auto it = BC.begin(); it != BC.end(); ++it) {
      for (int i = 0; i < it->first; i++) {
         rest.push_back(it->second);
         cnt0++;
         if (cnt0 > N) break;
      }
   }
   ll ans = 0;
   int cnt = 0;
   for (int i = 0; i < N; i++) {
      if (A[i] < CMax) {
         cnt++;
         rest.push_back(A[i]);
      } else ans += A[i];
   }
   sort(rest.rbegin(), rest.rend());

   for (int i = 0; i < cnt; i++) {
      ans += rest[i];
   }
   
   cout << ans << endl;

   return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

const int INF = 1000000000;
const ll M = 1000000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},
                         {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/*----------------------------------------------/
/- char         : %c  | char *       : %s  | short        : %hd
/- int          : %d  | long         : %ld | long long    : %lld
/- unsigned short:%hu | unsigned int : %u  | unsigned long: %lu
/- u_long long  : %llu| (octal)      : %o  | (hexadecimal): %x
/- float        : %f  | double       : %lf |
/----------------------------------------------*/

/*----------------------------------------------/
/- INT_MAX, LONG_MAX   : 1<<15 = 2.1*pow(10, 9)       (= 2147483647)
/- UINT_MAX, ULONG_MAX : 1<<16 = 4.2*pow(10, 9)       (= 4294967295)
/- LLONG_MAX           : 1<<63 = 9.2*pow(10, 18)      (= 9223372036854775807)
/- ULLONG_MAX          : 1<<64 = 1.8*pow(10, 19)      (= 18446744073709551615)
/----------------------------------------------*/

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int d = b / a;
    d = min(c, d);
    cout << d;

    /* ====================================== */
    cout << endl;
    return 0;
}

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

int main(void){
    long long h, w, s1=0, s2=0, s3=0;
    cin >> h >> w;
    s1 = (w+1)/3*h;
    long long tw = w-(w+1)/3;
    s2 = h/2*tw;
    s3 = h*w - s1 - s2;
    long long minS = min(s1, min(s2, s3)), maxS = max(s1, max(s2, s3));
    long long ans = maxS - minS;
    s2 = tw/2*h;
    s3 = h*w - s1 - s2;
    minS = min(s1, min(s2, s3)), maxS = max(s1, max(s2, s3));
    ans = min(ans, (maxS-minS));
    s1 = (h+1)/3*w;
    long long th = h-(h+1)/3;
    s2 = w/2*th;
    s3 = h*w - s1 - s2;
    minS = min(s1, min(s2, s3)), maxS = max(s1, max(s2, s3));
    ans = min(ans, (maxS-minS));
    s2 = th/2*w;
    s3 = h*w - s1 - s2;
    minS = min(s1, min(s2, s3)), maxS = max(s1, max(s2, s3));
    ans = min(ans, (maxS-minS));
    cout << ans << endl;
}

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

#define llint long long int

using namespace std;

int main(){
    int N;

    cin >> N;

    if(N <= 9){
        cout << N << endl;
    }else if(N <= 99){
        cout << 9 << endl;
    }else if(N <= 999){
        cout << 9 + N - 99 << endl;
    }else if(N <= 9999){
        cout << 9 + 900 << endl;
    }else if(N <= 99999){
        cout << 9 + 900 + N - 9999 << endl;
    }else{
        cout << 9 + 900 + 90000 << endl;
    }
}

Measured memory_bytes: 256
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define DEBUG(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(int argc, const char * argv[]) {
  std::cout << std::fixed << std::setprecision(15);

  int N; cin >> N;
  vector<int> A(N);
  ll ans = 0;
  rep(i, N){
    int a; cin >> a;
    int cnt = a / 2;
    if(cnt > 0){
      if(a % 2 == 0){
        A[i] = 2;
        cnt--;
      }
      else{
        A[i] = 1;
      }
    }
    else{
      if(a % 2 == 0){
        A[i] = 0;
      }
      else{
        A[i] = 1;
      }
    }

    ans += cnt;
  }

  rep(i, N){
    if(A[i] == 2){
      ans++;
      A[i] -= 2;
    }
    else if(A[i] == 1){
      if(i+1 <= N -1){
        if(A[i+1] == 2){
          A[i]--; A[i+1]--;
          ans++;
        }
        else if(A[i+1] == 1){
          A[i]--; A[i+1]--;
          ans++;
        }
      }
    }
  }

  cout << ans << endl;
}  


Measured memory_bytes: 640
using System;
using System.Linq;

namespace Sample101
{

    class Program
    {
        static void Main(string[] args)
        {
            // 入力
            var N = int.Parse(Console.ReadLine());
            var line = Console.ReadLine().Split(' ');
            var T = int.Parse(line[0]);
            var A = int.Parse(line[1]);
            var H = Console.ReadLine().Split(' ').Select(str => int.Parse(str)).ToArray();

            // 各地点の温度を計算しAに最も近いものを求める
            var nearT = Math.Abs(A - (T - H[0] * 0.006));
            var result = 0;

            for (int i = 1; i < N; i++)
            {
                // 温度を求めてAとの差を計算する
                var temp = Math.Abs(A - (T - H[i] * 0.006));
                // 比較してAにより近ければ入れ替える
                if (nearT > temp)
                {
                    nearT = temp;
                    result = i;
                }

            }


            Console.WriteLine(result + 1);
        }
    }
}

Measured memory_bytes: 13332
#include<stdio.h>
#define N 1000

int main(){

  int i, j, temp, n, array[N];

  scanf("%d",&n);

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

  for(i = 0; i < n; i++)
    {
      temp = array[i];

      for(j = i - 1; j >= 0; j--)
	{
	  if(array[j] > temp)
	    {
	      array[j + 1] = array[j];
	      array[j] = temp;
	    }
	      else {
	    array[j + 1] = temp;
	    break;
	  }
	}
      for(j = 0; j < n; j++)
	{
	  if(j == n - 1)
	    {
	      printf("%d\n",array[j]);
	      break;
	    }
	  printf("%d ",array[j]);
	}
    }
  return 0;
}



Measured memory_bytes: 2064
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int N,A,B,C;
int l[8];
int S[3];
int ans=1e9;
int score=0;

void dfs(int d){
  if(d==N){
    if(S[0]*S[1]*S[2]==0)return;
    int temp=score;
    int buff[3];
    REP(i,3)buff[i]=S[i];
    sort(buff,buff+3);
    temp+=max(buff[0],C)-min(buff[0],C);
    temp+=max(buff[1],B)-min(buff[1],B);
    temp+=max(buff[2],A)-min(buff[2],A);
    // cerr<<buff[0]<<" "<<buff[1]<<" "<<buff[2]<<" "<<temp<<endl;
    ans=min(ans,temp);
    return;
  }else{
    dfs(d+1);
    REP(i,3){
      bool f=0;
      if(S[i]!=0){
        score+=10;
        f=1;
      }
      S[i]+=l[d];
      dfs(d+1);
      S[i]-=l[d];
      if(f)score-=10;
    }

  }
}

int main(){
  cin>>N>>A>>B>>C;
  REP(i,N)cin>>l[i];
  dfs(0);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C: All Green
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_D = 10;
const int MAX_P = 100;
const int MAX_G = 200000;
const int INF = 1 << 30;

/* typedef */

/* global variables */

int ps[MAX_D], cs[MAX_D];
int dp[2][MAX_G + 1];

/* subroutines */

inline void setmin(int &a, int b) { if (a > b) a = b; }

/* main */

int main() {
  int d, g;
  scanf("%d%d", &d, &g);
  g /= 100;

  int maxg = 0;
  for (int i = 0; i < d; i++) {
    scanf("%d%d", &ps[i], &cs[i]);
    cs[i] /= 100;
    maxg += (i + 1) * ps[i] + cs[i];
  }
  //printf("maxg = %d\n", maxg);

  fill(dp[0], dp[0] + maxg + 1, INF);
  dp[0][0] = 0;
  int cur = 0, nxt = 1;

  for (int i = 0; i < d; i++) {
    int &pi = ps[i], &ci = cs[i];
    copy(dp[cur], dp[cur] + maxg + 1, dp[nxt]);
    for (int j = 1, s = i + 1; j <= pi; j++, s += i + 1) {
      if (j == pi) s += ci;
      for (int k = 0; k + s <= maxg; k++)
	if (dp[cur][k] < INF)
	  setmin(dp[nxt][k + s], dp[cur][k] + j);
    }
    cur ^= 1, nxt ^= 1;
  }

  int mindp = INF;
  for (int i = g; i <= maxg; i++) setmin(mindp, dp[cur][i]);
  printf("%d\n", mindp);
  return 0;
}


Measured memory_bytes: 1024
def is_even(num):
    if num % 2 == 0:
        return True
    else:
        return False

def is_split(num):
    if num % 3 == 0 or num % 5 == 0:
        return True
    else:
        return False

a = int(input())
li1 = list(map(int, input().split()))
li2 = []
flag = False

for i in range(a):
    li2.append(li1[i])

for i in li2:
    if is_even(i):
        if not is_split(i):
            flag = True

if flag:
    print("DENIED")
else:
    print("APPROVED")


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

int main() {
	// your code goes here
	long long a,b,x;
	cin >> a >> b >> x;
	if(a%x==0)
	cout << (b/x-a/x+1) << endl;
	else cout << (b/x-a/x) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 100000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    ll n,m,c;
    cin>>n>>m>>c;
    ll b[m];
    for(int i=0;i<m;i++){
        cin>>b[i];
    }
    int ans=0;
    for(int i=0;i<n;i++){
        ll a[m];
        ll tmp=c;
        for(int j=0;j<m;j++){
            cin>>a[j];
            tmp+=a[j]*b[j];
        }
        if(tmp>0){
            ans++;
        }
    }
    cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
tmp = sum(a)
for i in range(n):
  if a[i]<b[i]:
    b[i] -= a[i]
    a[i] = 0
    a[i+1] -= min(a[i+1],b[i])
  else :
    a[i] -= b[i]
print(tmp - sum(a))

Measured memory_bytes: 19116
#include<stdio.h>
#include<string.h>
int main(){
int i;
char c[1200];
fgets(c,sizeof(c),stdin);
for(i=0;i<strlen(c);i++)
{
    if(c[i]>='A' && c[i]<='Z')
    {

        printf("%c",c[i]=c[i]+32);
    }
    else if(c[i]>='a' && c[i]<='z')
    {

        printf("%c",c[i]=c[i]-32);
    }

    else
    {
        printf("%c",c[i]);
    }
}
return 0;
}



Measured memory_bytes: 2092
n,m=map(int, input().split())
if m%2==1:
    for i in range(m//2):
        print(i+1,m-i)
    for i in range(m//2+1):
        print(m+i+1,2*m+1-i)
else:
    for i in range(m//2):
        print(i+1,m+1-i)
    for i in range(m//2):
        print(m+i+2,2*m+1-i)

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

const int MAX = 2e5+10;

ll N, K;
int A[MAX];
vi idx[MAX];

vi solve() {
    REP (i, N) idx[A[i]].push_back(i);
    ll ped = 0;
    int n = 0;
    while (!(ped != 0 && n == 0)) {
        int a = A[n];
        auto iter = upper_bound(ALL(idx[a]), n);
        if (iter == idx[a].end()) {
            ped++;
            n = (idx[a][0] + 1) % N;
        } else {
            n = (*iter + 1) % N;
        }
        if (n == 0) ped++;
    }
    K %= ped;

    vi ans;
    n = 0;
    while (K) {
        int a = A[n];
        auto iter = upper_bound(ALL(idx[a]), n);
        if (iter == idx[a].end()) {
            if (K == 1) {
                ans.push_back(a);
                n = (n+1) % N;
            } else {
                K--;
                n = (idx[a][0] + 1) % N;
            }
        } else {
            n = (*iter + 1) % N;
        }
        if (n == 0) {
            K--;
        }
        if (K == 0) break;
    }
    return ans;
}

int main() {
    cin >> N >> K;
    REP (i, N) cin >> A[i];
    FORE (x, solve()) cout << x << " ";
    cout << endl;
}

Measured memory_bytes: 14964
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)

int main() {
  ll n, h, w; cin >> n >> h >> w;
  ll res = 0;
  rep(i, n) {
    ll a, b; cin >> a >> b;
    if (a>=h && b>=w) res++;
  }
  cout << res << endl;
}

Measured memory_bytes: 3528
#include <bits/stdc++.h>
#define ll long long

#define INF 999999999

using namespace std;

// input

string n;

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

    cin >> n;

    if(n[0] == '9' || n[1] == '9'){
        cout << "Yes" << "\n";
    }
    else{
        cout << "No" << "\n";
    }
    
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void)
{
	int a,b;
	cin>>a>>b;
	if((a==2 && b==3) || (a==3 && b==2)) cout<<"1\n"<<endl;
	if((a==1 && b==3) || (a==3 && b==1)) cout<<"2\n"<<endl;
	if((a==1 && b==2) || (a==2 && b==1)) cout<<"3\n"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <unistd.h>
#include <bits/stdc++.h>

#define pii pair<int,int>
#define REP(i, n) for (long long i = 0; i < (n); i++) 
using namespace std;

using Graph = vector<vector<int>>;

typedef long long ll;
static const ll INF = 1000000000000000000LL;
static const ll MOD = 1000000007;


map <int, int> x;
int main()
{
    int N;
    string res = "YES";
    
    cin >> N;

    REP(i,N)
    {
        int a;
        cin >> a;
        decltype(x)::iterator it = x.find(a);
        if (it != x.end())  // 見つかった
        {
            res = "NO";
            break;
        }
        x[a] = 1;

    }
    
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 9600
//Code By CXY07
#include<bits/stdc++.h>
using namespace std;

#define int long long

const int MAXN = 1;
const int INF = 2e9;
const int mod = 1e9 + 7;

int n,ans;

signed main () {
	cin >> n;
	for(register int i = 1;i <= n; ++i)
		if(i % 3 && i % 5) ans += i;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<bits/stdc++.h>
using namespace std;

int N, M;
string S;
long double R;

int main(){

    cin >> R;

    cout << 2.0*acos(-1)*R;


}


Measured memory_bytes: 3808
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
using namespace std;
int mark[100001],A[100001]; 
int main()
{
	int n,i,j,k,x,y,z,c=0;
	cin>>n;
	for(i=1;i<=n;i++)
	cin>>A[i];
	x=1;
	c=0;
	mark[1]=1;
	while(x!=2)
	{
		c++;
		x=A[x];
		if(mark[x])
		break;
		mark[x]=1;
	}
	if(x==2)
	cout<<c;
	else
	cout<<-1;
return 0;
}


Measured memory_bytes: 1024
class SegTree:
    """ segment tree with point modification and range product. """
    # # https://yukicoder.me/submissions/452850
    def __init__(self, N, data_f = min, data_unit=1<<30):
        self.N = N
        self.data_f = data_f
        self.data_unit = data_unit
        self.data = [self.data_unit] * (N + N)

    def build(self, raw_data):
        data = self.data
        f = self.data_f
        N = self.N
        data[N:] = raw_data[:]
        for i in range(N - 1, 0, -1):
            data[i] = f(data[i << 1], data[i << 1 | 1])

    def set_val(self, i, x):
        data = self.data
        f = self.data_f
        i += self.N
        data[i] = x
        while i > 1:
            data[i >> 1] = f(data[i], data[i ^ 1])
            i >>= 1

    def fold(self, L, R):
        """ compute for [L, R) """
        vL = vR = self.data_unit
        data = self.data
        f = self.data_f
        L += self.N
        R += self.N
        while L < R:
            if L & 1:
                vL = f(vL, data[L])
                L += 1
            if R & 1:
                R -= 1
                vR = f(data[R], vR)
            L >>= 1
            R >>= 1
        return f(vL, vR)
      
N=int(input())
S=input()
data = [[0]*N for _ in range(26)]
di = {}
for i in range(N):
  data[ord(S[i])-97][i] = 1
  di[i] = S[i]

seg = [SegTree(N,max,0) for _ in range(26)]
for i in range(26):
  seg[i].build(data[i])
Q=int(input())
for i in range(Q):
  *q, = input().split()
  if q[0] == '1':
    i, c = q[1:]
    i = int(i)-1
    c_old = di[i]
    di[i] = c
    seg[ord(c_old)-97].set_val(i,0)
    seg[ord(c)-97].set_val(i,1)
  else:
    l,r = map(int,q[1:])
    ans=0
    for i in range(26):
      ans += seg[i].fold(l-1,r)
    print(ans)

Measured memory_bytes: 526348
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int n,k; cin>>n>>k;
    int v[n]; rep(i,n) cin>>v[i];
    int ans=0;
    for(int l=0;l<=k;l++){
        for(int r=0;r<=k;r++){
            int push=k-(l+r);
            if(push<0) continue;
            if(l+r>n) continue;
            vector<int> get;
            for(int i=0;i<l;i++) get.push_back(v[i]);
            for(int i=0;i<r;i++) get.push_back(v[n-1-i]);
            sort(all(get));
            int sum=0;
            for(int i:get) sum+=i;
            for(int i=0;i<min(push,(int)get.size());i++){
                if(get[i]<0) sum-=get[i];
            }
            ans=max(ans,sum);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        a = [LI() for _ in range(10)]
        sm = {}
        for i in range(10**4):
            c = 0
            t = 10**3
            while t > 0:
                k = i // t % 10
                c = a[c][k]
                t //= 10
            sm[i] = c
        e = collections.defaultdict(set)
        for i in range(10):
            for j in range(10):
                for k in range(10):
                    for l in range(10):
                        t = i * 1000 + j * 100 + k * 10 + l
                        for m in range(10):
                            if i != m:
                                u = m * 1000 + j * 100 + k * 10 + l
                                e[t].add(u)
                            if j != m:
                                u = i * 1000 + m * 100 + k * 10 + l
                                e[t].add(u)
                            if k != m:
                                u = i * 1000 + j * 100 + m * 10 + l
                                e[t].add(u)
                            if l != m:
                                u = i * 1000 + j * 100 + k * 10 + m
                                e[t].add(u)
                            if i != j:
                                u = j * 1000 + i * 100 + k * 10 + l
                                e[t].add(u)
                            if j != k:
                                u = i * 1000 + k * 100 + j * 10 + l
                                e[t].add(u)
                            if k != l:
                                u = i * 1000 + j * 100 + l * 10 + k
                                e[t].add(u)

        r = 0
        for i in range(10**4):
            t = sm[i]
            if i % 10 != t and a[sm[i - i % 10 + t]][i % 10] == 0:
                r += 1
                continue
            f = False
            for m in range(10):
                if m == t:
                    continue
                if a[t][m] == 0:
                    f = True
                    r += 1
                    break
            if f:
                continue
            for k in e[i]:
                if a[sm[k]][t] == 0:
                    r += 1
                    break
        rr.append(r)


        break



    return '\n'.join(map(str, rr))


print(main())




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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for(int i=0; i<n; i++) cin >> v[i];
  sort(v.begin(), v.end());
  
  int ans = 0;
  for(int i=0; i<k; i++) ans += v[i];
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main()
{
	long long n, a, b; scanf ("%lld %lld %lld", &n, &a, &b);
	long long r = n / (a + b) * a;
	n %= (a + b);
	if (n < a) r += n;
	else r += a;
	printf ("%lld\n", r);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
int H,N;
cin>>H>>N;
vector<int> A(N);
for(int i=0; i<N; i++){
    cin>>A.at(i);
}
for(int i=0; i<N; i++){
    H-=A[i];
}
if(H<=0){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}
}

Measured memory_bytes: 768
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n >> k;
  if (n>k){
    cout<<"safe"<<endl;
    return 0;
  }else{
    cout<<"unsafe"<<endl;
    return 0;
  }

  return 0;
}

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

long int d() {
  long int N;
  long int K;
  cin >> N >> K;
  if (K == 0) return N * N;
  long int count = 0;
  for (long int b = K + 1; b <= N; ++b) {
    long int x = (N - K) / b;
    long int y = (N - b + 1) / b;
    if (x == y) {
      count += (b - K) * (x + 1);
    } else {
      count += (b - K) * (x + 1) - ((2 + y) * b - N - 1);
    }
  }
  return count;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << d() << endl;
  return 0;
}

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

void printArray(int A[], int N)
{
    for (int i = 0; i < N; i++) {
        cout << A[i];
        if (i != N - 1) {
            cout << ' ';
        }
    }
    cout << endl;
}

int main() {
    int A[1000], N, v, i, j;
    cin >> N;
    for (i = 0; i < N; i++) {
        cin >> A[i];
    }
    printArray(A, N);
    for (i = 1; i < N; i++) {
        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        printArray(A, N);
    }
    
    return 0;
}

Measured memory_bytes: 3112
export class Main {
  static main(input): string {
    const [one, two]: string[] = input.split("\n");
    const [H, W]: number[] = one.split(" ").map(Number);
    const [h, w]: number[] = two.split(" ").map(Number);
    return `${H * W - (H * w + h * (W - w))}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 7372
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(){
    long long n;
    cin >> n;
    string s = "";
    n--;
    while(1){
        long long p = n%26;
        char c = 'a' + p;
        s=c+s;
        if(n>=26){
            n=(n-p)/26-1;
        }else{
            break;
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <cstdio>

using namespace std;
using ll = long long;

const int M = 2e3 + 5;
ll n, k, arr[M], dp[M] = {0};

int main() {
    scanf("%lld", &n);
    for (int i = 0; i < n; i++) {
        scanf("%lld", arr + i);
    }
    dp[0] = 1;
    for (int i = 1; i < n; i++) {
        dp[i] = 1;
        if (arr[i - 1] <= arr[i]) {
            dp[i] = dp[i - 1] + 1;
            dp[i - 1] = 0;
        }
    }
    ll ans = 1000;
    for (int i = 1; i < n; i++) {
        if (dp[i]) {
            ll num = ans / arr[i - dp[i] + 1];
            // printf("%d ", num);
            ans -= num * arr[i - dp[i] + 1];
            ans += num * arr[i];
        }
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 3252
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    while(1){
        int N,M;
        int lis[100002];
        cin>>N>>M;
        if(N==0&&M==0)break;
        for(int i=0;i<N;i++)cin>>lis[i];
        int now=0,ans=0;
        for(int i=0;i<M;i++)now+=lis[i],ans+=lis[i];
        for(int i=1;i+M<=N;i++)now=now-lis[i-1]+lis[i+M-1],ans=max(now,ans);
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1548
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		String N = reader.next();
		int num = 0;
		for (int i = 0; i < N.length(); i++) {
			char ch = N.charAt(i);
			num += Character.getNumericValue(ch);
		}
		if (Integer.parseInt(N) % num == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}



		reader.close();
	}
}





Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES  // M_PI等のフラグ
#define MOD 1000000007
#define COUNTOF(array) (sizeof(array)/sizeof(array[0]))
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;


void solve(){
    string S;
    cin >> S;
    if (S.at(S.size()-1) != 's') {
        cout << S << "s" << endl;
    }
    else {
        cout << S << "es" << endl;
    }
}


int main(int argc, char const *argv[]){
    solve();
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  string s;
  cin>>s;
  bool ok=true;
  rep(i,0,sz(s))
    {
      if(i%2==0)
	{
	  if(s[i]=='L') ok=false;
	}
      else
	{
	  if(s[i]=='R') ok=false;
	}
    }
  if(ok) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
// #define ll long long
typedef long long ll;
typedef pair<int, int> P;



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

  int n;
  cin >> n;
  
  int p[n];
  rep(i,n) {
    cin >> p[i];
  }
  
  int sum_ = 0;
  rep(i,n){
    if (p[i] > (i+1)){
      // cout << i+1 << endl;
      sum_++;
    }
  }
  if (sum_  <= 1 ) {
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
int psum[100005];
int psum2[100005];
int main(){
	string a, b; cin >> a >> b;
  	for (int i = 1; i <= a.length(); i++){
        psum[i] = psum[i - 1] + (a[i - 1] == 'A' ? 1 : -1);
    }
    for (int i = 1; i <= b.length(); i++){
        psum2[i] = psum2[i - 1] + (b[i - 1] == 'A' ? 1 : -1);
    }
    int q; cin >> q;
    while (q--){
        int a, b, c, d; cin >> a >> b >> c >> d;
        if (((psum[b] - psum[a - 1]) - (psum2[d] - psum2[c - 1])) % 3 == 0) cout << "YES\n";
        else cout << "NO\n";
    }
}

Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<utility>
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

using namespace std;

int main(){
  int w,h;
  vector<string> s;
  queue<pair<int,int>> que;
  vector<vector<int>> d;
  int defi,defj;
  while(cin>>w&&cin>>h){
    if(!w&&!h)break;
    s.resize(h);
    d.resize(h);
    for(int i=0;i<h;i++)
      d[i].resize(w,0);
    for(int i=0;i<h;i++){
      cin >> s[i];
      for(int j=0;j<w;j++)
	if(s[i][j] == '@'){defi=i;defj=j;}
    }
    
    que.push(make_pair(defi,defj));
    int ct=1;//???????????????
    while(que.size()){
      pair<int,int> defp = que.front();
      que.pop();
      pair<int,int> p;
      for(int i=0;i<4;i++){
	p.first = defp.first + dy[i];p.second = defp.second + dx[i];
	if(p.first>=0 && p.second>=0 && p.first<h && p.second<w){
	  if(d[p.first][p.second])continue;
	  else if(s[p.first][p.second] == '.'){
	    ct++;
	    d[p.first][p.second]++;
	    que.push(p);
	  }else if(s[p.first][p.second] == '#'){
	    d[p.first][p.second]++;
	  }
	}
      }
    }
    cout << ct << endl;
    s.clear();
    d.clear();
  }
  return 0;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned int
#define test int t;cin>>t; while(t--)
#define en '\n'
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) (int)x.size()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
// You should only debug a pair of simple data types. For example,
// the debug won't work if one of pair's elements is collection type
// (std::vector, std::map, std::set...).
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


// bool check_prime(int n)  return whether a number is prime or not O(sqrt(N));
// int BE(int x,int n,int m)  return x^n%m; O(logN);
// void sieve()  from number 1-1000001 saare prime store kar lega  in bool is_prime[1000001] array
// vector<int> z_array(string s)  return vector which is Z-array of string s;
// vector<int> lps(string s)      return vector which is lps array of string s;
// int power(int x,int n) return x^n; O(logN);
// using_ordered_set (template for using ordered set , replace first 2 lines of this page with this code..);
const int gf = 1e6 + 9;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int k;
	cin >> k;
	zip(i, 0, k)cout << "ACL";


	return 0;
}




Measured memory_bytes: 3616
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

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

    int num = sc.nextInt();
    Map<Integer, Integer> used = new HashMap<>();
    for (int i = 0; i < num; i++) {
      int val = sc.nextInt();
      if (used.get(val) != null) {
        System.out.println("NO");
        return;
      } else {
        used.put(val, i);
      }
    }
    System.out.println("YES");
  }
}


Measured memory_bytes: 103344
n = map(int, raw_input().split())
x = n[1]
n = n[0]
tpl = x
# print '55',tps, tpl
if x < float(n)/2:
    tps = abs(n - 2*x)
    l = x + n - tps
else:
    l = 0
    tps = n - x
while tps != 0:
    # print l
    # print "t", tps, tpl
    l += tpl/tps * 3*tps  # tpl/tps * 3*tps
    ntps = tpl % tps
    tpl = tps
    tps = ntps
print l

Measured memory_bytes: 2568
H, W, N = tuple(map(int, input().split()))
r, c = tuple(map(int, input().split()))
r-=1
c-=1
Ta = input()
Ao = input()
L, R, U, D = -1, W, -1, H
for idx, (t, a) in enumerate(zip(reversed(Ta), reversed(Ao))):
    if idx != 0:
        if(a == "R"):
            L = max(L-1,-1)
        elif(a == "L"):
            R = min(R+1,W)
        elif(a == "U"):
            D = min(D+1,H)
        else:
            U = max(U-1,-1)
            
    #print("A{} L{} c{} R{} U{} r{} D{}".format(a,L,c,R,U,r,D))
    if(t == "R"):
        R = max(R-1,-1)
    elif(t == "L"):
        L = min(L+1,W)
    elif(t == "U"):
        U = min(U+1,H)
    else:
        D = max(D-1,-1)
    #print("T{} L{} c{} R{} U{} r{} D{}".format(t,L,c,R,U,r,D))
    if (R-L-1)*(D-U-1) <= 0:
        print("NO")
        quit()
print("YES" if L < c < R and U < r < D else "NO")


Measured memory_bytes: 51244
#include <stdio.h>
#include <stdlib.h>
int gcd(int p,int q){while(q){int t=p%q;p=q;q=t;}return p;}

char s[110];
int main(){
	int n,x;
	scanf("%d%d",&n,&x);
	int ans=0;
	for(int i=0;i<n;i++){
		int t;
		scanf("%d",&t);
		ans=gcd(ans,t-x);
	}
	printf("%d",abs(ans));
}

Measured memory_bytes: 128
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

// デフォルト変数定義
int n,m,a,b,c,d,x,y,z;
string s,t;
//

signed main() {
  RAPID;
  IN4(a,b,c,d);
  if(a+b==c+d) OUT("Balanced");
  else if(a+b>c+d) OUT("Left");
  else OUT("Right");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<ll,ll>;
#define For(i,a,b)  for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
#define F first
#define S second
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define bpc __builtin_popcount
#define MOD (ll)(1e9+7)
#define INF (2e9)
#define EPS (1e-6)
#define NATHANLEE_IS_EVIL_AND_ELECTRIC true
#define int ll
#ifdef LOCAL_TEST
#define debug(...) do{\
	cerr<<__PRETTY_FUNCTION__<<" - "<<__LINE__<<\
	" : ("#__VA_ARGS__<<") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T>void _OUT(T x){cerr<<x<<"\n";}
template<typename T,typename...I>void _OUT(T x,I ...tail){cerr<<x<<", ";_OUT(tail...);}
#else
#define debug(...)
#endif
void INIT(){
#ifdef LOCAL_TEST
	freopen("D:\\input.in","r",stdin);
	freopen("D:\\output.out","w",stdout);
	freopen("D:\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(!NATHANLEE_IS_EVIL_AND_ELECTRIC);
	cin.tie(0);
}

ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll fpow(ll b,ll p){
	b%=MOD;
	ll ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int dp[3010][3010];
int a[3010];

int go(int i,int j,bool f){
	if(i==j){
		if(f) return  a[i];
		else  return -a[i];
	}
	if(dp[i][j]!=-1) return dp[i][j];
	if(f) dp[i][j]=max(go(i+1,j,!f)+a[i],go(i,j-1,!f)+a[j]);
	else  dp[i][j]=min(go(i+1,j,!f)-a[i],go(i,j-1,!f)-a[j]);
	return dp[i][j];
}

int32_t main() {
	INIT();
	//code...
	int n; cin>>n;
	For(i,0,n-1) cin>>a[i];
	memset(dp,-1,sizeof(dp));
	cout<<go(0,n-1,true)<<"\n";
	return 0;
}

Measured memory_bytes: 74652
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
ll mod =  1000000007;
ll maxn = 1000000000;
 
//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------
 
int main(){
    string s;
    cin>>s;
    if(s.at(2)==s.at(3)&&s.at(4)==s.at(5))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
   



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

ll dp[410][410];
int N, C;
int A[410];
int B[410];

const ll mod = 1e9+7;
ll ps[410][410];

int main()
{
	read(N, C);
	
	for(int j=1; j<=400; ++j){
		ps[0][j] = 1;
		for(int i=1; i<=C; ++i){
			ps[i][j] = ps[i-1][j] * j % mod;
		}
	}
	for(int i=0; i<=C; ++i){
		for(int j=1; j<=400; ++j) (ps[i][j] += ps[i][j-1]) %= mod;
	}
	
	for(int i=1; i<=N; ++i) read(A[i]);
	for(int i=1; i<=N; ++i) read(B[i]);
	dp[0][0] = 1;
	for(int i=1; i<=N; ++i){
		for(int k=0; k<=C; ++k){
			for(int j=0; j<=k; ++j){
				(dp[i][k] += dp[i-1][k-j] * (ps[j][B[i]] - ps[j][A[i]-1] + mod)) %= mod;
			}
		}
	}
	printf("%lld\n", dp[N][C]);
	return 0;
}


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

long long int a,b,q,i;
vector<long long int> s,t,x;


int main(){
    cin>>a>>b>>q;
    s.resize(a+2);
    t.resize(b+2);
    x.resize(q);
    for(i=1;i<=a;i++){
        cin>>s[i];
    }
    for(i=1;i<=b;i++){
        cin>>t[i];
    }
    for(i=0;i<q;i++){
        cin>>x[i];
    }
    s[0]=t[0]=-500000000000;//両端に番兵
    s[a+1]=t[b+1]=500000000000;

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

    vector<long long int> ans(q);
    long long int key1,key2;
    vector<long long int>::iterator position;
    
    for(i=0;i<q;i++){//二分探索
        position=lower_bound(s.begin(),s.end(),x[i]);
        key1=distance(s.begin(),position);//xより大きい最小値の場所(sにおいて)

        position=lower_bound(t.begin(),t.end(),x[i]);
        key2=distance(t.begin(),position);//xより大きい最小値の場所(tにおいて)

        ans[i]=500000000000;
        
        //最小値を探す
        ans[i]=min(ans[i],max(s[key1]-x[i],t[key2]-x[i]));
        ans[i]=min(ans[i],max(x[i]-s[key1-1],x[i]-t[key2-1]));
        ans[i]=min(ans[i],s[key1]+x[i]-2*t[key2-1]);
        ans[i]=min(ans[i],2*s[key1]-x[i]-t[key2-1]);
        ans[i]=min(ans[i],t[key2]+x[i]-2*s[key1-1]);
        ans[i]=min(ans[i],2*t[key2]-x[i]-s[key1-1]);
    }
    for(i=0;i<q;i++){
        printf("%lld\n",ans[i]);
    }
    return 0;
}

Measured memory_bytes: 4480