akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

map<ll, ll> prime_factor(ll n)
{
    map<ll, ll> ret;
    for (ll i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}
struct factorial
{
    vector<ll> fac, finv, inv;

    factorial(int n) : fac(2, 1), finv(2, 1), inv(2, 1)
    {
        int i;

        rep(i, 2, n + 1)
        {
            fac.push_back(fac[i - 1] * i % MOD);
            inv.push_back(MOD - inv[MOD % i] * (MOD / i) % MOD);
            finv.push_back(finv[i - 1] * inv[i] % MOD);
        }
    }

    ll comb(int n, int k)
    {
        if (n < k)
        {
            return 0;
        }

        if (n < 0 || k < 0)
        {
            return 0;
        }

        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }

    ll perm(int n, int k)
    {
        if (n < k)
        {
            return 0;
        }

        if (n < 0 || k < 0)
        {
            return 0;
        }

        return fac[n] * finv[n - k] % MOD;
    }
};

int main(void)
{
    ll n, m;

    factorial f(1e6);

    cin >> n >> m;

    map<ll, ll> a = prime_factor(m);

    ll ans = 1;

    for (auto x : a)
    {
        ans *= f.comb(x.second + n - 1, x.second);
        ans %= MOD;
    }

    cout << ans << endl;
}


Measured memory_bytes: 24508
import sys
import itertools
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


A = list(input())
B = list(input())
C = list(input())


def compare(arr1, arr2):
    for x, y in zip(arr1, arr2):
        if x == y or x == '?' or y == '?':
            continue
        return False

    return True


def can_match(x, y):
    return x == '?' or y == '?' or x == y


CONST = 2005
ans = len(A) + len(B) + len(C)


for A, B, C in itertools.permutations([A, B, C]):

    A_to_B = [True] * CONST
    B_to_C = [True] * CONST
    A_to_C = [True] * (CONST * 2)

    lenA = len(A)
    lenB = len(B)
    lenC = len(C)

    for i in range(lenA+1):
        A_to_B[i] = compare(A[i:], B)

    for i in range(lenB + 1):
        B_to_C[i] = compare(B[i:], C)

    for i in range(lenA+1):
        A_to_C[i] = compare(A[i:], C)

    for i in range(CONST):
        for j in range(CONST):
            if A_to_B[i] and B_to_C[j] and A_to_C[i + j]:
                right = max(lenA, i + lenB, i + j + lenC)
                ans = min(ans, right)

print(ans)


Measured memory_bytes: 57948
#include<iostream>
#include<cmath>


int main(){
  int n;
  double xa,ya,ra,xb,yb,rb,d;
  std::cin >> n;

  for(int i=0;i<n;i++){
    std::cin >> xa >> ya >> ra
             >> xb >> yb >> rb;
    d = std::sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb));
    if(ra+rb < d){
      std::cout << 0 << std::endl;
      continue;
    }
    if(ra+d < rb){
      std::cout << -2 << std::endl;
      continue;
    }
    if(rb+d < ra){
      std::cout << 2 << std::endl;
    }else{
      std::cout << 1 << std::endl;
    }
    //cout << (d<=ra+rb?d+rb>=ra?d+ra>=rb?1:-2:2:0) << endl;
  }
}

Measured memory_bytes: 3140
import java.util.*;
class Main{
	public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      Set t = new HashSet<Integer>();
      boolean ok = true;
      for(int i = 0;i<a;i++){
        t.add(sc.nextInt());
      }

      if(t.size()==a)System.out.println("YES");
      else System.out.println("NO");
    }
}

Measured memory_bytes: 100576
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

typedef long long ll;
ll lucasnum[100];
ll lucas(int N){
    if(lucasnum[N] != 0)
        return lucasnum[N];
    else
        return lucasnum[N] = lucas(N-1) + lucas(N-2);
}

int main()
{
    int N;
    cin >> N;
    lucasnum[0] = 2;
    lucasnum[1] = 1;
    cout << lucas(N) << endl;
    return 0;
}

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

int main() {
    int A,B,s;
    cin >> A >> B;
    int ans = 0;
    string n;

    for (int i = A; i < B+1; i++)
    {
        n = to_string(i);
        s = n.length();
        if(n[0] == n[4] && n[1] == n[3])
        {
            ++ans;
        }
        
        //++N;
    };

    cout << ans << endl;
    
}


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

#define REP(idx, end) for(int idx = 0; idx < end; ++idx)
#define DBG(x) cerr << #x << ": " << x << "\n"

using namespace std;
typedef long long lint;
const int MOD = 1000000007;

int main() {

	cin.tie(0);

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

	A = (A + 11) % 13;
	B = (B + 11) % 13;

	DBG(A);
	DBG(B);

	if (A > B)cout << "Alice";
	else if (A < B)cout << "Bob";
	else cout << "Draw";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    int n;
    cin >> n;
    cout << pow(2,int(log2(n))) << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import math
n =int(input())

ALPHABET = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
result = []

def alphabet_decimal(v):
    quotient = math.floor(v / len(ALPHABET))
    surplus = v % len(ALPHABET)
    quotient -= 1 if surplus == 0 else 0
    surplus = len(ALPHABET) if surplus == 0 else surplus
    result.append(surplus)
    if len(ALPHABET) < quotient:
        alphabet_decimal(quotient)
    elif len(ALPHABET) < v:
        result.append(quotient)
    return "".join([ALPHABET[i - 1] for i in reversed(result)])

print(alphabet_decimal(n))

Measured memory_bytes: 9212
/*g++ main.cpp -o main.out*/
/*./main.out*/
/*std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);*/

#include<bits/stdc++.h>
using namespace std;

#define LL long long
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(n,a) memset(n,a,sizeof(n));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int a[55];

int main()
{
    int n,k,ans=0;
    cin>>n>>k;
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    red(i,n-1,n-k)
    {
        ans+=a[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
use std::cmp;

fn main() {
    let mut sc = Scanner::new();
    let n = sc.read();
    let mut x: Vec<usize> = vec![0; n];
    let mut y: Vec<usize> = vec![0; n];
    for i in 0..n {
        x[i] = sc.read();
        y[i] = sc.read();
    }

    let mut small = vec![];
    let mut large = vec![];
    for i in 0..n {
        small.push(cmp::min(x[i], y[i]));
        large.push(cmp::max(x[i], y[i]));
    }

    let &small_min = small.iter().min().unwrap();
    let &small_max = small.iter().max().unwrap();
    let &large_min = large.iter().min().unwrap();
    let &large_max = large.iter().max().unwrap();
    let mut ans = (small_max - small_min) * (large_max - large_min);

    let worst_side = large_max - small_min;
    let mut max = small_max;
    let mut min = 1e15 as usize;

    let mut v = vec![];
    for i in 0..n {
        v.push((small[i], large[i]));
    }
    v.sort();

    for i in 0..(n - 1) {
        let (_, large) = v[i];
        let (next_small, _) = v[i + 1];
        min = cmp::min(min, large);
        max = cmp::max(max, large);
        let tmp_min = cmp::min(min, next_small);
        ans = cmp::min(ans, (max - tmp_min) * worst_side);
    }
    println!("{}", ans);
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read_vec<T>(&mut self, n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        (0..n).map(|_| self.read()).collect()
    }

    fn usize_read(&mut self) -> usize {
        self.read()
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


Measured memory_bytes: 18452
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int n;
int a[1100];

void insertionSort(int a[], int n)
{
  rep(i, n){
    int v = a[i];
    int j = i-1;
    while(0<=j && v<a[j]){
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;
    rep(j, n){
      if(j!=n-1) cout << a[j] << " ";
      else cout << a[j];
    }
    cout << endl;
  }
}

int main(){
  cin >> n;
  rep(i, n) cin >> a[i];

  insertionSort(a, n);

  return 0;
}









Measured memory_bytes: 3076
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

long w, h, n;
long b[5];

int main(){
    scanf("%ld%ld%ld", &w, &h, &n);
    b[1] = 0;
    b[2] = w;
    b[3] = 0;
    b[4] = h;
    for(int i = 0; i < n; i++){
        long x, y, a;
        scanf("%ld%ld%ld", &x, &y, &a);
        if(a == 1){
            b[1] = std::max(b[1], x);
        }else if(a == 2){
            b[2] = std::min(b[2], x);
        }else if(a == 3){
            b[3] = std::max(b[3], y);
        }else{
            b[4] = std::min(b[4], y);
        }
    }
    if(b[1] >= b[2] || b[3] >= b[4]){
        printf("0\n");
    }else{
        printf("%ld\n", (b[2]-b[1]) * (b[4]-b[3]));
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define true 0
#define false 1

int kaibun(char str[], int s, int l) {
  for (int i = s; i < l/2; i++) {
   	if (str[i] != str[l-i-1])
        return false;
  }
  return true;
}

int main() {
  char str[100];
  int len;
  
  scanf("%s\n", str);
  len = strlen(str);
  
  if ( kaibun(str, 0, len) == true ) {
    if ( kaibun(str, 0, (len-1)/2) == true ) {
      if ( kaibun(str, (len+3)/2, len-(len+3)/2) == true ) {
        printf("Yes\n");
        return 0;
      }
    }
  }
  printf("No\n");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int N; cin >> N;
  Graph plan(N, vi(3));
  rep(i,N) rep(j,3) cin >> plan[i][j];

  vi now(3, 0);
  rep(i,N) {
    int d = abs(plan[i][1] - now[1]) + abs(plan[i][2] - now[2]);
    int tmp = (plan[i][0] - now[0]) - d;
    if (tmp < 0 || tmp%2) {
      cout << "No\n";
      return 0;
    }
    now = plan[i];
  }

  cout << "Yes\n";
  return 0;
}


Measured memory_bytes: 5760
! 2019.12.29
!
      program answer
      implicit none
      integer(8) :: A,B,K
!
      read(*,*) A,B,K
      if(A < K) then
        B = B+A-K
        A = 0
        if(B < 0) then
          B = 0
        end if
      else
        A = A-K
      end if
      write(*,*) A,B
      end program answer

Measured memory_bytes: 640
N = int(input())
As = sorted(map(int, input().split()))

used = [False] * N

ans = 0
for i in range(31, 0, -1):
    power_of_two = 1 << i
    l = 0
    r = N - 1
    while True:
        while l < N and used[l]:
            l += 1
        while r >= 0 and used[r]:
            r -= 1
        if l >= r:
            break

        if As[l] + As[r] == power_of_two:
            used[l] = True
            used[r] = True
            l += 1
            r -= 1
            ans += 1
        elif As[l] + As[r] < power_of_two:
            l += 1
        else:
            r -= 1

print(ans)



Measured memory_bytes: 108920
MAX = 2000
MOD = 10**9+7
fac= [0]*MAX 
finv= [0]*MAX
inv = [0]*MAX


def COMinit():
    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1
    for i in range(2,MAX):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

def COM(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD

n, k = list(map(int, input().split()))
COMinit()
for i in range(1,k+1):
    a1 = COM(n-k+1, i)
    a2 = COM(k-1,i-1)
    ans = (a1*a2)%MOD
    print(ans)


Measured memory_bytes: 3572
import scala.io.Source

object Main {
  def main(args: Array[String]) = {
    val lines = Source.stdin.getLines
    val numLine = lines.next.toInt
    val numbers = lines.take(numLine).toSeq.map(l => l.split(" ").map(_.toInt).toSeq)

    val res = (Seq(0,0,0) +: numbers).take(numLine).zip(numbers).map {
      case (prev, next) => {
        val time = next(0) - prev(0)
        val distance = math.abs(next(1) - prev(1)) + math.abs(next(2) - prev(2))
        (time % 2) == (distance % 2) && (distance <= time)
      }
    }.reduce(_ && _)
    println(if (res) "Yes" else "No")
  }
}


Measured memory_bytes: 100836
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const field = input.slice(0, -1).map((line) => line[0]);

  return field.join("") ===
    field
      .reverse()
      .map((row) => row.split("").reverse().join(""))
      .join("")
    ? "YES"
    : "NO";
};

console.log(main(read()));


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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 55, M = 110;

LL k, a[N];

int main()
{
	cin >> k;
	for (int i = 0, t = 0; i < 50; i ++ )
	{
		if (i == 50LL - k % 50LL) t = 1;
		a[i] = i + t + k / 50LL;
	}
	
	puts("50");
	for (int i = 0; i < 50; i ++ ) cout << a[i] << ' ';
	return 0;
}

Measured memory_bytes: 256
S = list(input())

Odd = S[0::2]
Even = S[1::2]

for i in range(len(Odd)):
    if 'L' == Odd[i]:
        l = 0
        break
    else:
        l = 1

r = 1
for j in range(len(Even)):
    if 'R' == Even[j]:
        r = 0
        break
    else:
        r = 1

if l+r == 2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
from decimal import *

n = int(input())

a = []; b = []
ans = 0
for i in range(n):
    ai, bi = map(int,input().split())
    a.append(ai); b.append(bi)
a.sort()
b.sort()

if n % 2 == 1:
    med = (n + 1) // 2
    ans = (b[med - 1] - a[med - 1]) + 1
    print(int(ans))
else:
    med0 = n // 2
    med1 = (n // 2) + 1
    amed = (Decimal(a[med0-1])+Decimal(a[med1-1]))/Decimal(2)
    bmed = (Decimal(b[med0-1])+Decimal(b[med1-1]))/Decimal(2)
    ans = int(((bmed - amed) * Decimal(2) + Decimal(1)))
    print(ans)


Measured memory_bytes: 26248
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int main(void){
  int N;
  scanf("%d", &N);

  double ans;

  if (N % 2 == 0) {
    ans = (double)1/2;
    printf("%f\n", ans);
  }
  if(N % 2 == 1){
    int a = N / 2;
    ans = (double)(a+1)/N;
    printf("%f\n", ans);
  }

}


Measured memory_bytes: 128
import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29

def main():
    a,b = map(int,input().split())
    ans = []
    x = int(min(a//0.08,b//0.1))
    y = int(max((a+1)//0.08,b//0.1))
    for i in range(x,y+1):
        if int(i*0.08)==a and int(i*0.1)==b:
            ans.append(i)
    if len(ans):
        print(min(ans))
    else:
        print(-1)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38384
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int num[ 26 ];

int main()
{
	string w;
	cin >> w;
	for( auto c : w ) ++num[ c - 'a' ];
	bool isOK = true;
	REP( i, 26 ) if( num[ i ] % 2 != 0 ) { isOK = false; break; }
	cout << ( isOK ? "Yes" : "No" ) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <assert.h>
#include <limits.h>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

//const ll MOD = 998244353;
const ll MOD = 1e9+7;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll x,y;
  std::cin>>x>>y;
  std::cout<<x+(y/2);
  return 0;
}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
ll LCM(int a, int b){
    return a*b/gcd(a,b);
}



int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    for(int i=a;i<=100*a;i+=a){
        if(i%b==c){cout<<"YES"<<endl; return 0;}
    }
    cout<<"NO"<<endl;
    return 0;

}

Measured memory_bytes: 256
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
   string n;
  
 
   cin >> n;
  
  if(n[2]==n[3]&&n[4]==n[5]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
   
   
  return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
// ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int M;
ll K;
int main(){
	cin>>M>>K;
	ll hoge=1;
	rep(i,M)hoge*=2;
	if(M==1){
		if(K==0)cout<<"0 0 1 1"<<endl;
		else cout<<-1<<endl;
		return 0;
	}
	if(hoge>K){
		cout<<K<<" ";
		for(int i=0;i<hoge;i++){
			if(i!=K)cout<<i<<" ";
		}
		cout<<K<<" ";
		for(int i=hoge-1;i>=0;i--){
			if(i!=K)cout<<i<<" ";
		}
		cout<<endl;
	}else{
		cout<<-1<<endl;
	}
}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	X = inputInt()

	for i in range(X, 10000000000):
		if is_prime(i):
			print(i)
			sys.exit()

def is_prime(n):
    i = 2
    while i * i <=n:
        if n % i == 0:
            return False
        i += 1
    return True

if __name__ == "__main__":
	main()


Measured memory_bytes: 38512
n = int(input())
s = input()
li = []
b_li1 = []
b_li2 = []
for i in range(0, n-2):
    if s[i] in b_li1:
        continue
    b_li1.append(s[i])
    for j in range(i+1, n-1):
        if s[i]+s[j] in b_li2:
            continue
        b_li2.append(s[i]+s[j])
        for k in range(j+1, n):
            li.append(s[i]+s[j]+s[k])
print(len(set(li)))


Measured memory_bytes: 227316
def comb_mod(n,r,m):
    ans = 1
    for i in range(1,r+1):
        ans *= (n-i+1) % m
        ans *= pow(i,m-2,m) % m
        ans = ans % m
    return ans

x,y = map(int,input().split())
m = 10**9+7
if x > 2*y or 2*x < y or (x+y)%3 != 0:
    ans = 0
else:
    n = (x+y)//3
    r = x-n
    ans = comb_mod(n,r,m)
print(ans)

Measured memory_bytes: 9148
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 10010;
int n,k,cnt[N];
char s[N],t[N];

inline int lg(int n){
	int x=1,ret=0;
	while (x<n) x<<=1,++ret;
	return ret;
}

int main(){
	scanf("%d%d%s",&n,&k,s+1);
	int mn=1e9;
	For(i,1,n) mn=min(mn,(int)s[i]);
	if (k>1+lg(n)){
		For(i,1,n) printf("%c",mn);
		return 0;
	}
	while (k>1){
		For(i,1,n) t[i]=s[i];
		For(i,1,n) t[n+i]=s[n-i+1];
		For(i,1,n*2) 
			if (mn==t[i]) cnt[i]=cnt[i-1]+1;
				else cnt[i]=0;
		int pos=n;
		For(i,n+1,n*2){
			if (cnt[i]>cnt[pos]) pos=i;
			else if (cnt[i]==cnt[pos]){
				bool flag=0;
				For(j,1,n-cnt[i]) if (t[pos-cnt[i]-j+1]!=t[i-cnt[i]-j+1]){
					if (t[pos-cnt[i]-j+1]>t[i-cnt[i]-j+1]) flag=1;
					break;
				}
				if (flag) pos=i; 
			}
		}
		For(i,1,n) s[i]=t[pos-n+i];
		--k;
	}
	For(i,1,n) t[i]=s[i];
	For(i,1,n) t[n+i]=s[n-i+1];
	int pos=n;
	For(i,n+1,n*2){
		bool flag=0;
		Dow(j,n,1) if (t[pos-j+1]!=t[i-j+1]){
			if (t[pos-j+1]>t[i-j+1]) flag=1;
			break;
		}
		if (flag) pos=i;
	}
	For(i,1,n) s[i]=t[pos-n+i];
	For(i,1,n) printf("%c",s[i]);
}

Measured memory_bytes: 3824
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>
#include <fstream>

using namespace std;


ifstream in("input.txt");
ofstream out("output.txt");


template<typename T1, typename T2>inline void chkmin(T1& x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void chkmax(T1& x, T2 y) { if (x < y) x = y; }
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define PI 3.14159265358979323846

typedef unsigned long long ll;

const int maxn = 3e5 + 228;

int n, k;

int a[maxn];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    int ans = 1e9;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    for (int i = 1; i <= 100; ++i) {
        int c = 0;
        for (int j = 0; j < n; ++j) {
            c += (a[j] - i) * (a[j] - i);
        }
        ans = min(ans, c);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)
def f(k):
  if k==0:return 0
  if k<0: return 100000
  if dp[k]!=-1:return dp[k]
  f1=f(k-1)+abs(h[k]-h[k-1])
  f2=f(k-2)+abs(h[k]-h[k-2])
  dp[k]=min(f1,f2)
  return dp[k]
n=int(input())
h=list(map(int,input().split()))
dp=[-1]*n
print(f(n-1))


Measured memory_bytes: 94200
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br =  BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (h, w, k) = readIntegerList()
    val grid = Array(h) { br.readLine()!!.toCharArray() }
    val numOfBlack = grid.fold(0) { acc, line -> acc + line.count { it == '#' } }

    var ans = 0
    for (state in 0 until (1 shl h)) {
        for (state2 in 0 until (1 shl w)) {
            var tmp = numOfBlack
            for (i in 0 until h) {
                for (j in 0 until w) {
                    if (((((state shr i) and 1) == 1) || ((state2 shr j) and 1) == 1)
                        && grid[i][j] == '#') {
                        tmp--
                    }
                }
            }

            if (tmp == k) ans++
        }
    }
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 36596
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>


#define rep(i,p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;

//130 A

int main(void) {
	int x, a;
	cin >> x >> a;
	if (x < a)cout << 0 << endl;
	else cout << 10 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int num = 0;
  scanf("%d\n", &num);
  int height[num];
  for (int i=0; i<num; i++) {
    scanf("%d", height+i);
  }
  int count = 0;
  for (int i=0; i<num; i++) {
    int flag = 1;
    for (int j=0; j<i; j++) {
      if (height[i] < height[j]) {
        flag = 0;
        break;
      }
    }
    if (flag) count++;
  }
  printf("%d\n", count);
  return 0;
}


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

  string s;
  cin >> s;

  int count=0;
  for(int i=0;i<(int)(s.length());i++){
    if((i+1)%2 == 1){
      if(s[i] != 'L'){
        count++;
      }
    }
    if((i+1)%2 == 0){
      if(s[i] != 'R'){
        count++;
      }
    }
  }

  if((int)(s.length())==count){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
MOD = 10**9 + 7


def main():
    N = int(input())
    AN = map(int, input().split())

    digits_ct = [(0, 0) for _ in range(65)]

    for A in AN:
        temp = A

        length = 0
        for _ in range(65):
            digit = temp & 0b1

            zero, one = digits_ct[length]
            if digit == 0:
                digits_ct[length] = (zero + 1, one)
            else:
                digits_ct[length] = (zero, one + 1)

            temp = temp >> 1
            length += 1

    ans = 0
    radix = 1
    for digit_ct in digits_ct:
        zero, one = digit_ct
        ans += (((zero * one) % MOD) * radix) % MOD
        ans = ans % MOD

        radix *= 2

    print(ans)


main()


Measured memory_bytes: 125624
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    string s;
    std::deque<string> deq;
    char c;
    int flag=0;
    for (int i=0;i<n;i++) {
        cin>>s;
        if (i==0) {
            deq.emplace_back(s);
            c=s.at(s.size()-1);
        } else {
            if (c!=s.at(0)) {
                cout<<"No"<<endl;
                flag=1;
                break;
            } else if (find(deq.begin(),deq.end(),s)!=deq.end()) {
                cout<<"No"<<endl;
                flag=1;
                break;
            } else {
                deq.emplace_back(s);
                c=s.at(s.size()-1);
            }
        }
    }
    if (flag==0) {
        cout<<"Yes"<<endl;
    }
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 1e6 + 5;
const ll inf = 1e12;


int n;
double x[maxn], y[maxn];
char d[maxn];


double sim(double t) {
    double xlo=inf,xhi=-inf,ylo=inf,yhi=-inf;
    for (int i=0; i<n; i++) {
	double X = x[i];
	double Y = y[i];
	if (d[i]=='U') Y += t;
	if (d[i]=='D') Y -= t;
	if (d[i]=='L') X -= t;
	if (d[i]=='R') X += t;
	xlo=min(xlo,X);
	xhi=max(xhi,X);
	ylo=min(ylo,Y);
	yhi=max(yhi,Y);
    }

    return (xhi-xlo)*(yhi-ylo);
}

const double eps = 1e-7;

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

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

    double lo = 0;
    double hi = 2e8;


    for (int iter=0; iter<500; iter++) {
	double mid1 = lo + (hi-lo)/3;
	double mid2 = hi - (hi-lo)/3;
	double res1 = sim(mid1);
	double res2 = sim(mid2);
	if (res1 < res2) {
	    hi = mid2;
	} else {
	    lo = mid1;	    
	}
    }

    cout<<fixed<<setprecision(15)<<sim(lo)<<endl;    //15 too much..?
    return 0;
}


Measured memory_bytes: 5404
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // get a string
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        if (c > a) {
            c -= a;
            a = 0;
            b = b > c ? b - c : 0;
        } else {
            a -= c;
        }
        // output
        System.out.printf("%d %d%n",a, b);
    }
}

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



int main()
{
   string s1,s2;
   cin>>s1>>s2;
   int count=0;
   
   for(int i=0;i<s1.length();i++)
   {
       if(s1[i]!=s2[i])
           count++;
   }
   
 cout<<count;

    return 0;
}

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

public class Main {

  private void solve(InputReader in, PrintWriter out) {
    String s = in.next();
    int count = 0;
    for (char c : s.toCharArray()){
      if (c == '2') count++;
    }
    out.println(count);
  }

  private static int gcd(int n, int m) {
    return m == 0 ? n : gcd(m, n % m);
  }


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

  private void run() {

    try (InputReader in = new InputReader(System.in);
         PrintWriter out = new PrintWriter(System.out)) {
      solve(in, out);
    }
  }


  static class InputReader implements AutoCloseable {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    InputReader(InputStream stream) {
      //reader = new BufferedReader(new FileReader(stream), 32768);
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    @Override
    public void close() {
    }
  }

}


Measured memory_bytes: 22612
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
   int n,k;
   cin>>n>>k;
   int h[n];
   for(int i=0;i<n;i++){
      cin>>h[i];
   }
   sort(h,h+n);
   int ans=1000000000;
   for(int i=0;i<=n-k;i++){
      int sa=h[i+k-1]-h[i];
      if(ans>sa)ans=sa;
   }
   cout<<ans<<endl;
}
   


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#include<functional>
#include<limits>
#include <unordered_map>
#include <numeric>
#include <array>
#include <queue>
#include <chrono>
#include <random>
#include <fstream>


using namespace std;
using  ull = unsigned long long int;

#define rep(i,n,m) for(long long int i=n;i<(long long int)(m);i++)
#define INF (1<<29)
#define MD 1000000007




int main() {

	
	string str;
	cin >> str;

	int cnt = 0;

	rep(i, 0, str.length()) {
		if (str[i] == '+')cnt++;
		else cnt--;
	}

	cout << cnt << endl;




	return 0;
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll N; cin >> N;
  vector<ll> a(N); rep(i, N) cin >> a[i];
  ll h = a[0];
  ll ans = 0;
  rep(i, N) {
    if(a[i] <= h) {
      ans += h - a[i];
    } else {
      h = a[i];
    }
  }
  cout << ans << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 4840
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int X = sc.nextInt();

    int[] x = new int[N];

    for (int i = 0; i < N; i++) {
      x[i] = sc.nextInt();
    }

    sc.close();

    long g = Math.abs(x[0] - X);

    for (int i = 1; i < N; i++) {
       g = gcd(g, Math.abs(x[i] - X));
    }

    System.out.println(g);

  }

  public static long gcd(long x, long y){

    if (x < y) {
      long t = x;
      x = y;
      y = t;
    }

    while (y > 0) {
      long r = x % y;
      x = y;
      y = r;
    }

    return x;
    
  }

}

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

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

    string s[n];

    long ans = 0;

    int xa = 0;
    int bx = 0;
    int ba = 0;

    for(int i = 0; i < n; i++) {
        cin >> s[i];
        int end = s[i].size() - 1;

        for (int j = 0; j < end - 1; j++) {
            if (s[i][j] == 'A' && s[i][j + 1] == 'B') {
                ans++;
            }
        }

        if (s[i][0] == 'B' && s[i][end] == 'A') {
            //cout << s[i] << " ba" << endl;
            ba++;
        } else if (s[i][0] == 'B') {
            //cout << s[i] << " bx" << endl;
            bx++;
        } else if (s[i][end] == 'A') {
            //cout << s[i] << " xa" << endl;
            xa++;
        } else {
            //cout << s[i] << " --" << endl;
        }
    }

    //cout << "xa " << xa << endl;
    //cout << "bx " << bx << endl;
    //cout << "ba " << ba << endl;

    if (ba == 0) {
        ans += min(xa, bx);
    } else {
        if (xa + bx > 0) {
            ans += (ba + min(xa, bx));
        } else {
            ans += (ba - 1);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 768
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

int main()
{
	string S;
	cin >> S;
	int K;
	cin >> K;
	int N = (int)S.size();
	vector<vector<vector<int>>> dp(N + 2, vector<vector<int>>(N + 2, vector<int>(K + 1)));
	for (int l = N; l > 0; l--) {
		for (int r = l; r <= N; r++) {
			for (int k = 0; k <= K; k++) {
				if (S[l - 1] == S[r - 1]) {
					dp[l][r][k] = dp[l + 1][r - 1][k] + (l == r ? 1 : 2);
				} else {
					dp[l][r][k] = max(dp[l + 1][r][k], dp[l][r - 1][k]);
					if (k > 0) 
						dp[l][r][k] = max(dp[l][r][k], dp[l + 1][r - 1][k - 1] + (l == r ? 1 : 2));
				}
			}
		}
	}
	int ans = dp[1][N][K];
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main()
{
	vector<int> A(9);
	for (int i = 0; i < 9; i++)
	{
		cin >> A.at(i);
	}
	vector<bool> Ab(9,false);

	int N;
	cin >> N;

	for (int i = 0; i < N; i++) 
	{
		int b;
		cin >> b;
		for (int j = 0; j < 9; j++) 
		{
			if (A.at(j) == b) 
			{
				Ab.at(j) = true;
			}
		}
	}

	if (Ab.at(0) == true && Ab.at(1) == true && Ab.at(2) == true ||
		Ab.at(3) == true && Ab.at(4) == true && Ab.at(5) == true ||
		Ab.at(6) == true && Ab.at(7) == true && Ab.at(8) == true ||
		Ab.at(0) == true && Ab.at(3) == true && Ab.at(6) == true ||
		Ab.at(1) == true && Ab.at(4) == true && Ab.at(7) == true ||
		Ab.at(2) == true && Ab.at(5) == true && Ab.at(8) == true ||
		Ab.at(0) == true && Ab.at(4) == true && Ab.at(8) == true ||
		Ab.at(2) == true && Ab.at(4) == true && Ab.at(6) == true) 
	{
		cout << "Yes" << endl;
	}
	else 
	{
		cout << "No" << endl;
	}


	return 0;
}

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


int main() {
	int N;
	cin >> N;
	vector<char> s(N);
	for(int i = 0; i < N; i++){
		cin >> s.at(i);
	}
	bool three = true;
	for(int i = 0; i < N; i++){
		if(s.at(i) == 'Y'){
			three = false;
			break;
		}
	}
	if(three){
		cout << "Three" << endl;
	}
	else{
		cout << "Four" << endl;
	}
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M));
    for(int i = 0; i < N; i++){
        cin >> C[i];
        for(int j = 0; j < M; j++) cin >> A[i][j];
    }
    set<int> ok;
    int min_c = INT_INF;
    for(int bit = 0; bit < (1 << N); bit++){
        int cost = 0;
        vector<int> A_sum(M, 0);
        for(int i = 0; i < N; i++){
            if(bit & (1 << i)){
                cost+=C[i];
                for(int j = 0; j < M; j++){
                    A_sum[j] += A[i][j];
                }
            }
        }
        bool ok = true;
        for(int a : A_sum) if(a < X) ok = false;
        if(ok) min_c = min(min_c, cost);
    }
    if(min_c == INT_INF) puts("-1");
    else cout << min_c << endl;
}


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

ll k;
vector<ll> all;

void dfs2(ll nm, int dg){
  	all.push_back(nm);
  	if(dg == 11) return;
  	
	for(int i = -1; i <= 1; i++){
      	if(!(i == -1 && nm%10 == 0) && !(i == 1 && nm%10 == 9)){
    		dfs2(nm*10+nm%10+i, dg+1);
        }
    }
  		
  	return;
}

void dfs(){
	for(int i = 1; i < 10; i++){
      	dfs2(i,1);
    }
  	return;
}

int main() {
	cin >> k;
  	dfs();
  	sort(all.begin(),all.end());
  	cout << all.at(k-1) << endl;
}

Measured memory_bytes: 11568
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007
#define dancila 3.14159265359
#define eps 1e-9
 
using namespace std;
 
typedef long long ll;
 
 
int add(int a, int b)
{
    int x = a+b;
    if(x >= mod)
        x -= mod;
    if(x < 0)
        x += mod;
    return x;
}
ll mul(ll a, ll b)
{
    return (a*b) % mod;
}
 
ll pw(ll a, ll b)
{
    ll ans = 1;
    while(b)
    {
        if(b & 1)
            ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}
 
ll cnt[100005];
int main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    int n, k;
    cin >> n >> k;
    cnt[k] = 1;
    ll ans = k;
    for(int i = k-1; i >= 1; --i)
    {
        int rp = k/i;
        cnt[i] = pw(rp, n);
        for(int j = i+i; j <= k; j += i)
        {
            cnt[i] = cnt[i] + mod - cnt[j];
            if(cnt[i] >= mod)
                cnt[i] -= mod;
        }
        ans += 1LL * cnt[i] * i;
        ans %= mod;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 4428
#include<iostream>
#include <string.h>
char S[11], T[11], U[11];
int Count[2];
int main(){
    std::cin >> S >> T >> Count[0] >> Count[1] >> U;
    if(strcmp(S, U)==0){
        if(Count[0]>0) Count[0]--;
    }else if(strcmp(T, U)==0){
        if(Count[1]>0) Count[1]--;
    }
    std::cout << Count[0] << " " <<Count[1] << "\n";
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
ans = 0 ;count = 0 ;pro = 1

n=int(input())

def f(a,b):
    return max(len(str(a)),len(str(b)))

ans=inf
for i in range(1,int(math.sqrt(n))+1):
    if n%i==0:
        ans=min(ans,f(i,n//i))

print(ans)


Measured memory_bytes: 39024
#include<stdio.h>

int main(void){
	int N, i;
	/*N,iの読み込み*/
	do{
		scanf("%d%d", &N, &i);
	}while(N <= 1 && N >= 100 && i <= 1 && i >= N);
	/*結果の表示*/
	printf("%d\n", N - i + 1);

	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int A[n];
    int count=0,max=0;
    for(int i=0;i<n;i++){
        cin>>A[i];
        if(A[i]==1){
            count+=1;
            continue;
            }
        else{
            if(max<count){
                max=count;
            }
            count=0;
        }
    }
    if(max<count){
        max=count;
    }
    cout<<max+1<<endl;
    return 0;
}


Measured memory_bytes: 3108
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int X, Y;
    cin >> X >> Y;
    int answer = 0;

    if (X <= 3) answer += (4 - X) * 1e5;
    if (Y <= 3) answer += (4 - Y) * 1e5;
    if (X == 1 && Y == 1) answer += 4e5;

    cout << answer << '\n';
}


Measured memory_bytes: 256