akhauriyash/Code-Regression huggingface dataset:
N, A, B = map(int, input().split())
P = []
Q = []
ans = 0
for i in range(N):
    a, b = map(int, input().split())
    v = abs(a-b)
    if v <= A or B <= v <= 2*A:
        ans += 1
        continue
    if a > b:
        P.append(a-b)
    else:
        Q.append(a-b)

import collections
class Dinic:
    def __init__(self, n):
        self.n = n
        self.g = [[] for i in range(n)]
    def add_edge(self, fr, to, cap):
        self.g[fr].append([to, cap, len(self.g[to])])
        self.g[to].append([fr, 0, len(self.g[fr])-1])
    def add_multi_edge(self, v1, v2, cap1, cap2):
        self.g[v1].append([v2, cap1, len(self.g[v2])])
        self.g[v2].append([v1, cap2, len(self.g[v1])-1])
    def bfs(self, s):
        level = [-1]*self.n
        deq = collections.deque()
        level[s] = 0
        deq.append(s)
        while deq:
            v = deq.popleft()
            for e in self.g[v]:
                if e[1]>0 and level[e[0]]<0:
                    level[e[0]] = level[v] + 1
                    deq.append(e[0])
        self.level = level
    def dfs(self, v, t, f):
        if v==t: return f
        es = self.g[v]
        level = self.level
        for i in range(self.it[v], len(self.g[v])):
            e = es[i]
            if e[1]>0 and level[v]<level[e[0]]:
                d = self.dfs(e[0], t, min(f, e[1]))
                if d>0:
                    e[1] -= d
                    self.g[e[0]][e[2]][1] += d
                    self.it[v] = i
                    return d
        self.it[v] = len(self.g[v])
        return 0
    def max_flow(self, s, t):
        flow = 0
        while True:
            self.bfs(s)
            if self.level[t]<0: break
            self.it = [0]*self.n
            while True:
                f = self.dfs(s, t, 10**9+7)
                if f>0:
                    flow += f
                else:
                    break
        return flow

dinic = Dinic(2+len(P)+len(Q))
LP = len(P)
for i in range(len(P)):
    dinic.add_edge(0, 2+i, 1)
for j in range(len(Q)):
    dinic.add_edge(2+LP+j, 1, 1)
for i, p in enumerate(P):
    for j, q in enumerate(Q):
        v = abs(p+q)
        if v <= A or B <= v <= 2*A:
            dinic.add_edge(2+i, 2+LP+j, 1)
ans += dinic.max_flow(0, 1)
print(ans)


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

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int H, W;
	cin >> H >> W;
	vector<string> V(H);
	for(int i = 0; i < H; i++) cin >> V[i];
	vector< vector<int> > cnt(H, vector<int>(W, H*W+1));
	cnt[0][0] = (V[0][0] == '#');
	for(int i = 0; i < H; i++) for(int j = 0; j < W; j++) {
		if(i < H-1) cnt[i+1][j] = min(cnt[i+1][j], cnt[i][j] + (V[i][j] != V[i+1][j]));
		if(j < W-1) cnt[i][j+1] = min(cnt[i][j+1], cnt[i][j] + (V[i][j] != V[i][j+1]));
	}
	int ans = (cnt[H-1][W-1] + (V[H-1][W-1] == '#')) / 2;
	cout << ans << "\n";
}


Measured memory_bytes: 384
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int[] a = new int[N + 1];
    for (int i = 1; i <= N; i++) a[i] = scanner.nextInt();

    int[] b = new int[N + 1];
    for (int i = N; i >= 1; i--) {
      for (int j = 2; i * j <= N; j++) b[i] ^= b[i * j];
      b[i] ^= a[i];
    }
    StringBuilder sb = new StringBuilder();
    int count = 0;
    for (int i = 1; i <= N; i++) {
      if (b[i] == 1) {
        sb.append(i).append(' ');
        count++;
      }
    }
    System.out.println(count);
    if (sb.length() > 0) {
      sb.setLength(sb.length() - 1);
      System.out.println(sb);
    }
  }
}


Measured memory_bytes: 79364
import heapq
n,m=map(int,input().split())
d=[]
for i in range(n):
  a,b=map(int,input().split())
  d.append([a,b])
d=sorted(d, key=lambda student: student[0])
pointer=0
queue=[]
ans=0
for i in range(m+1):
  while pointer<n and d[pointer][0]==i:
    heapq.heappush(queue,-d[pointer][1])
    pointer+=1
    if pointer>=n:
      break
  if queue:
    ans+=heapq.heappop(queue)
print(-ans)

Measured memory_bytes: 96084
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
using namespace std;
#define LL long long

LL read() {
	LL x = 0, f = 1; char c = getchar();
	while(!isdigit(c)){ if(c == '-') f = -1; c = getchar(); }
	while(isdigit(c)){ x = x * 10 + c - '0'; c = getchar(); }
	return x * f;
}

int main() {
	LL l = read(), orgl = l, r = read(), orgr = r, tr = r, ans;
	
	for(int i = 59; i >= 0; i--)
		if((l ^ r) >> i & 1) {
			l |= 1ll << i;
			int tmp = i;
			for(tmp--; tmp >= 0; tmp--) tr |= 1ll << tmp;
			for(i--; i >= 0 && !(r >> i & 1); i--) ;
			for(i; i >= 0; i--) r |= 1ll << i;
			break;
		}
	if(r >= l) return printf("%lld\n", tr - orgl + 1), 0;
	ans = r - orgl + 1 + tr - l + 1;
	
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 256
import numpy as np

a = input()
b = input()
c = input()
d = input()
e = input()

menu = [int(a), int(b), int(c), int(d), int(e)]

menu_ = [int(a[-1]), int(b[-1]), int(c[-1]), int(d[-1]), int(e[-1])]
menu_index = [i for i, x in enumerate(menu_) if x == 0]

menu_ = np.array(menu_)
sort_menu = np.argsort(-menu_)
if len(menu_index) == 0:
    menu_index = sort_menu 
else:
    for i in sort_menu[:-len(menu_index)]:
        menu_index.append(i)

sum = 0
for i, j in enumerate(menu_index):
    sum = sum + menu[j]
    if i == len(menu_index) -1:
        break
    if not sum % 10 == 0:
        sum = sum + (10 - sum % 10)

print(sum)

Measured memory_bytes: 12444
x = input()

st_sub = 0
count = 0
for char in x:

    if st_sub < 0 and char == "S":
        st_sub = 1
    elif char == "S":
        st_sub += 1
    else:
        st_sub -= 1
    
    if st_sub < 0:
        count += 1
    
print(count * 2)

Measured memory_bytes: 3500
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author verytable
 */

#include <iostream>
#include <fstream>

#include <iostream>

class TaskA {
public:
	void solve(std::istream& in, std::ostream& out) {
		int X, t;
		in >> X >> t;
		out << std::max(0, X - t);
	}
};


int main() {
	TaskA solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace ALDS1_3_D_raiburari_
{
    class Program
    {
        class Pond
        {
            public int ichi;
            public int area;

            public Pond(int ichi, int area)
            {
                this.ichi = ichi;
                this.area = area;
            }
        }

        static void Main(string[] args)
        { 
            string c = Console.ReadLine();
            c += "w";

            int i = 0, kyori = 0, sum = 0;

            Stack<int> s1 = new Stack<int>();
            Stack<Pond> s2 = new Stack<Pond>();
            
            while (true)
            {
                if (c[i] == '\\')
                {
                    s1.Push(i);
                }
                else if (c[i] == '/' && s1.Count > 0)
                {
                    int j = s1.Pop();
                    kyori = i - j;
                    sum += kyori;

                    while (s2.Count > 0 && s2.Peek().ichi > j)
                    {
                        kyori += s2.Peek().area;
                        s2.Pop();
                    }

                    s2.Push(new Pond(j,kyori));
                }            
                else if (c[i] == 'w')
                {
                    break;
                }
                i++;
            }

            int k = s2.Count;

            Console.WriteLine(sum);
            Console.Write(k);

            StringBuilder sb = new StringBuilder();
            for (int j = 0; j < k; j++)
            {
                sb.Insert(0, " " + s2.Pop().area);
            }

            Console.WriteLine(sb);
        }

      
    }
}

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

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++) cin >> a[i];
    
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    
    int suma, sumb;
    suma = sumb = 0;
    
    for(int i=0; i<N; i++){
        if(i%2==0) suma += a[i];
        else sumb += a[i];
    }
    
    cout << suma-sumb << endl;
}


Measured memory_bytes: 256
class Factorial():
    def __init__(self, mod=10**9 + 7):
        self.mod = mod
        self._factorial = [1]
        self._size = 1
        self._factorial_inv = [1]
        self._size_inv = 1

    def __call__(self, n):
        return self.fact(n)

    def fact(self, n):
        ''' n! % mod '''
        if n >= self.mod:
            return 0
        self._make(n)
        return self._factorial[n]
    
    def _make(self, n):
        if n >= self.mod:
            n = self.mod
        if self._size < n+1:
            for i in range(self._size, n+1):
                self._factorial.append(self._factorial[i-1]*i % self.mod)
            self._size = n+1

    def fact_inv(self, n):
        ''' n!^-1 % mod '''
        if n >= self.mod:
            raise ValueError('Modinv is not exist! arg={}'.format(n))
        self._make(n)
        if self._size_inv < n+1:
            self._factorial_inv += [-1] * (n+1-self._size_inv)
            self._size_inv = n+1
        if self._factorial_inv[n] == -1:
            self._factorial_inv[n] = self.modinv(self._factorial[n])
        return self._factorial_inv[n]
    
    @staticmethod
    def xgcd(a, b):
        '''
        Return (gcd(a, b), x, y) such that a*x + b*y = gcd(a, b)
        '''
        x0, x1, y0, y1 = 0, 1, 1, 0
        while a != 0:
            (q, a), b = divmod(b, a), a
            y0, y1 = y1, y0 - q * y1
            x0, x1 = x1, x0 - q * x1
        return b, x0, y0

    def modinv(self, n):
        g, x, _ = self.xgcd(n, self.mod)
        if g != 1:
            raise ValueError('Modinv is not exist! arg={}'.format(n))
        return x % self.mod

    def comb(self, n, r):
        ''' nCr % mod '''
        if r > n:
            return 0
        t = self(n)*self.fact_inv(n-r) % self.mod
        return t*self.fact_inv(r) % self.mod
    
    def comb_(self, n, r):
        '''
        nCr % mod
        when r is not large and n is too large
        '''
        c = 1
        for i in range(1, r+1):
            c *= (n-i+1) * self.fact_inv(i)
            c %= self.mod
        return c

    def comb_with_repetition(self, n, r):
        ''' nHr % mod '''
        t = self(n+r-1)*self.fact_inv(n-1) % self.mod
        return t*self.fact_inv(r) % self.mod

    def perm(self, n, r):
        ''' nPr % mod '''
        if r > n:
            return 0
        return self(n)*self.fact_inv(n-r) % self.mod

n, m = map(int, open(0).read().split())
if abs(n-m) > 1:
    print(0)
else:
    mod = 10**9 + 7
    fact = Factorial()
    t = fact(n) * fact(m) % mod
    if n == m:
        print(2*t % mod)
    else:
    	print(t)

Measured memory_bytes: 12848
import java.util.*;

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

        //AC, WA, TLE, RE

        int AC=0;
        int WA=0;
        int TLE=0;
        int RE=0;
        String[] x = new String[n];
        for(int i=0;i<n;i++){
            x[i]=sc.next();
        }

        String comp = "";
        for(int i=0;i<n;i++) {
            comp=x[i];
            if ("AC".equals(comp)) {
                AC = AC+1;
            } else if ("WA".equals(comp)) {
                WA = WA+1;
            } else if ("TLE".equals(comp)) {
                TLE = TLE+1;
            } else {
                RE = RE+1;
            }
        }

        System.out.println("AC x "+AC);
        System.out.println("WA x "+WA);
        System.out.println("TLE x "+TLE);
        System.out.println("RE x "+RE);
    }
}



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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;

const ll e5 = 1 << 20;
const ll mod = 998244353;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

int main() {
  int h, w;
  cin >> h >> w;

  int row[h][w];
  queue<pair<int,int>> search;

  rep(i, h) {
    rep(j, w) {
      char tmp;
      cin >> tmp;
      if (tmp == '#') {
        row[i][j] = 0;
        search.push({i, j});
      } else {
        row[i][j] = INT_MAX;
      }
    }
  }

  while (!search.empty()) {
    int i = search.front().first;
    int j = search.front().second;
    search.pop();

    int im = i - 1;
    int ip = i + 1;
    int jm = j - 1;
    int jp = j + 1;;

    if (im >= 0 && row[im][j] > row[i][j] + 1) {
      search.push({im, j});
      row[im][j] = row[i][j] + 1;
    }
    if (ip < h && row[ip][j] > row[i][j] + 1) {
      search.push({ip, j});
      row[ip][j] = row[i][j] + 1;
    }
    if (jm >= 0 && row[i][jm] > row[i][j] + 1) {
      search.push({i, jm});
      row[i][jm] = row[i][j] + 1;
    }
    if (jp < w && row[i][jp] > row[i][j] + 1) {
      search.push({i, jp});
      row[i][jp] = row[i][j] + 1;
    }
  }

  int ans=0;
  rep(i, h) {
    rep(j, w) {
        ans = max(ans, row[i][j]);
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 12304
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    int n;
    cin >> n;
    int k;
    vector<vector<int> > v(n);
    for(int i=0;i<n-1;i++){
        int a,b;
        cin >> a >> b;
        a--,b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    vector<int> p(n);
    priority_queue<pair<int,int> > pq;
    vector<bool> flag(n);
    cin >> k;
    for(int i=0;i<k;i++){
        int a,b;
        cin >> a >> b;
        a--;
        p[a] = b;
        flag[a]=1;
        pq.push(MP(b,a));
        
    }
    bool ng = 0;
    while(!pq.empty()){
        auto x = pq.top();
        pq.pop();
        int y = x.second;
        for(auto z:v[y]){
            if(flag[z]==1){
                if(abs(p[y]-p[z])!=1){
                    ng = 1;
                }
            }else{
                flag[z]=1;
                p[z] = x.first-1;
                pq.push(MP(p[z],z));
            }
        }
        if(ng)break;
    }
     if(ng){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
        rep(i,n){
            cout << p[i] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 7924
import sys
input=sys.stdin.readline

class list2D:
    def __init__(self, H, W, num):
        self.__H = H
        self.__W = W
        self.__dat = [num] * (H * W)

    def __getitem__(self, a):
        return self.__dat[a[0]*self.__W+a[1]]

    def __setitem__(self, a, b):
        self.__dat[a[0]*self.__W+a[1]] = b

    def debug(self):
        print(self.__dat)

class list3D:
    def __init__(self, H, W, D, num):
        self.__H = H
        self.__W = W
        self.__D = D
        self.__X = W * D
        self.__dat = [num] * (H * W * D)

    def __getitem__(self, a):
        return self.__dat[a[0]*self.__X+a[1]*self.__D + a[2]]

    def __setitem__(self, a, b):
        self.__dat[a[0]*self.__X+a[1]*self.__D + a[2]] = b

    def debug(self):
        print(self.__dat)

def main():
    r,c,k=map(int,input().split())
    v = list2D(r, c, 0)

    for _ in range(k):
        ri,ci,a=map(int,input().split())
        v[ri-1, ci-1] = a

    dp = list3D(r, c, 4, 0)
    #print(dp)
    if v[0, 0]>0: dp[0, 0, 1]=v[0, 0]

    for i in range(r):
        for j in range(c):
            val = v[i, j]
            if i>0:
                x = max(dp[i-1, j, 0], dp[i-1, j, 1], dp[i-1, j, 2], dp[i-1, j, 3])
                dp[i, j, 1]=max(dp[i, j, 1],x+val)
                dp[i, j, 0]=max(dp[i, j, 0],x)

            if j>0:
                X = dp[i, j-1, 0]
                Y = dp[i, j-1, 1]
                V = dp[i, j-1, 2]
                Z = dp[i, j-1, 3]
                dp[i, j, 0]=max(dp[i, j, 0],X)
                dp[i, j, 1]=max(dp[i, j, 1],X+val,Y)
                dp[i, j, 2]=max(dp[i, j, 2],Y+val,V)
                dp[i, j, 3]=max(dp[i, j, 3],V+val,Z)

    #print(dp)
    ans=0
    for i in range(4): ans=max(dp[r-1, c-1, i],ans)
    return print(ans)
if __name__=="__main__":
    main()


Measured memory_bytes: 430212
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let w: usize = read();
    const INF: i64 = std::i64::MAX / 3;
    let v_max: usize = 1000 * n + 1;
    // (weight, value)
    let mut vec: Vec<(i64, i64)> = vec![];
    for _ in 0..n {
        vec.push((read(), read()));
    }
    let mut dp: Vec<Vec<i64>> = vec![vec![INF; v_max + 1]; n + 1];
    dp[0][0] = 0;
    for i in 0..n {
        for j in 0..v_max {
            if j < vec[i].1 as usize {
                dp[i + 1][j] = dp[i][j];
                continue;
            }
            dp[i + 1][j] = std::cmp::min(dp[i][j - vec[i].1 as usize] + vec[i].0, dp[i][j])
        }
    }
    let mut max_val = 0;
    for v1 in dp {
        for (i, &v2) in v1.iter().enumerate() {
            if v2 <= w as i64 {
                max_val = std::cmp::max(max_val, i);
            }
        }
    }

    println!("{}", max_val);
}


Measured memory_bytes: 106748
#include <stdio.h>
#include <stdlib.h>

int check(int n, int m, int *A, int M, long sum) {
  if(m == n) {
    if (sum == M) {
      return 1;
    }
    return 0;
  }
  int v0 = check(n,m+1,A,M,sum);
  if (v0 == 1) {
    return 1;
  }
  if (sum + A[m] <= M) {
    int v1 = check(n,m+1,A,M,sum+A[m]);
    if (v1 == 1) {
      return 1;
    }    
  }

  return 0;
}

  

int main()
{
  int i,n,*A,q,M;
  scanf("%d",&n);
  A = (int*)malloc(sizeof(int) * n);
  for (i = 0; i < n; i++) {
    scanf("%d",A+i);
  }
  scanf("%d",&q);
  for (i = 0; i < q; i++) {
    scanf("%d",&M);
    if(check(n,0,A,M,0) == 1) {
      printf("yes\n");
    }else {
      printf("no\n");
    }
  }
  
  
  return 0;
}

Measured memory_bytes: 580
#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
const double PI=acos(-1);
typedef long long ll;
typedef pair<int,int> pi;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for (int i=(a);i<=(b);i++)
#define per(i,a,b) for (int i=(a);i>=(b);i--)
#define Rep(i,a,b) for (int i=(a);i<(b);i++)
#define Per(i,a,b) for (int i=(a);i>(b);i--)
//debug
#define deb printf("begin\n");
#define dee printf("end\n");
#define def printf("find\n");
#define dey printf("Yes\n");
#define den printf("No\n");
#define dew printf("wrong\n");
void read(int&x){
	x=0;int f=1;char ch=getchar();
	while ((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if (ch=='-')f=-1,ch=getchar();
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=f;
}
//--------------------------head--------------------------//

#define maxn 405
#define maxQ 100005
bool vis[maxn][maxn];
int n,Q,x[maxQ],y[maxQ];
int main(){
	read(n);read(Q);
	rep(i,1,Q)read(x[i]),read(y[i]);
	memset(vis,0,sizeof(vis));
	rep(i,1,Q){
		if (vis[x[i]][y[i]]){rep(j,1,n)vis[j][x[i]]=vis[x[i]][j]=vis[j][y[i]]=vis[y[i]][j]=true;}
		else {rep(j,1,n){
				if (vis[j][x[i]])vis[j][y[i]]=vis[y[i]][j]=true;
				if (vis[j][y[i]])vis[j][x[i]]=vis[x[i]][j]=true;
			}
		}
		vis[x[i]][y[i]]=vis[y[i]][x[i]]=true;
	}
	int ans=0;
	rep(i,1,n)rep(j,i+1,n)if (!vis[i][j])ans++;
	printf("%d\n",ans);return 0;
}

Measured memory_bytes: 1280
/* ABC137-B
   Takatan */

#include<stdio.h>
#define NUM 1000000
int main(void){
    int number, stone, i;

    scanf( "%d %d" , &number, &stone);
    stone=stone-number+1;

    if(stone<-NUM){
        stone = -NUM; /* 最小の数が-NUMになる場合 */
    }
    printf( "%d" , stone); /* 最小の数字の出力 */
    for(i=1; i < 2 * number - 1; i++){
        stone++;
        if(stone>NUM){ /* 最大の数がNUMになる場合 */
            break;
        }
        printf( " %d" , stone); /* 順番に出力 */
    }
    printf( "\n" );
    return 0;
}

Measured memory_bytes: 128
N = int(input())
A = [list(map(int, input().split())) for _ in range(2)]
C = [[0] * N for _ in range(2)]
C[0][0] = A[0][0]
C[1][0] = A[1][0] + C[0][0]
for i in range(N - 1):
  C[0][i + 1] = A[0][i + 1] + C[0][i]
  C[1][i + 1] = A[1][i + 1] + max(C[1][i], C[0][i + 1])
print(C[1][N - 1])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repab(i,a,b) for(int i=a;i<=b;i++)
#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define pop pop_back
#define p0(x) cout<<x<<" "
#define p1(x) cout<<x<<'\n'
#define p2(x,y) cout<<x<<" "<<y<<'\n';
#define p3(x,y,z) cout<<x<<" "<<y<<" "<<z<<'\n'
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define get(n) int n;cin>>n
#define getll(n) ll n;cin>>n
#define getarr(arr,n) int arr[n];for(int i=0;i<n;i++) cin>>arr[i];
#define getstr(s) string s;cin>>s
#define countBits(x) __builtin_popcount (x)
using namespace std;

int main(){
  fio;
  get(n);get(a);get(b);
  ll ans=min(a*n,b);
  p1(ans);
  return 0;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, std::vector<long long> B){
    LL ans = B[N-2];
    RREP(i, N-2) {
        if( i != 0 ) {
            ans += min(B[i-1], B[i]);
        } else {
            ans += B[0];
        }
    } 

    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> B(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&B[i]);
    }
    solve(N, std::move(B));
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

    int rectanglesCount = 0;
    int lozengesCount = 0;
    while (input.ready())
    {
      String[] INPUT_STR = input.readLine().split(",");
      int a = Integer.valueOf(INPUT_STR[0]);
      int b = Integer.valueOf(INPUT_STR[1]);
      int c = Integer.valueOf(INPUT_STR[2]);

      if (isLozenges(a, b, c))
      {
        lozengesCount++;
      }
      else if (isRectangle(a, b, c))
      {
        rectanglesCount++;
      }

    }
    System.out.println(rectanglesCount);
    System.out.println(lozengesCount);

  }

  private static boolean isRectangle(int a, int b, int c)
  {
    if (a != b && Math.pow(a, 2) + Math.pow(b, 2) == Math.pow(c, 2))
    {
      return true;
    }
    return false;
  }

  private static boolean isLozenges(int a, int b, int c)
  {
    if (a == b)
    {
      return true;
    }
    return false;
  }

}

Measured memory_bytes: 24352
# 3 8 3   n l t
# 0 1     x w
# 3 2
# 6 1

n, l, t = gets.split.map(&:to_i)

array_x = []
array_w = []
n.times do 
  x_temp, w_temp = gets.split.map(&:to_i)
  array_x << x_temp
  array_w << w_temp
end

def round_once_plus(array)
  array << array[0]
  array.shift
end

def round_once_minus(array)
  array.unshift(array.last)
  array.pop
end

array_position = []
count_over = 0

array_x.each_with_index do |x, i|
  if array_w[i] == 1
    array_position << (x + t) % l
    count_over += (x + t) / l
  else # array_w[i] == 2
    array_position << (x - t) % l
    count_over += (x - t) / l
  end
end

array_position.sort!

if count_over > 0
  # count_over = count_over % l
  count_over.times do
    round_once_plus(array_position)
  end
elsif count_over < 0
  count_over = count_over.abs
  # count_over = count_over % l
  count_over.times do
    round_once_minus(array_position)
  end
end

puts array_position


Measured memory_bytes: 17780
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int dp[110][4][2];

int main(){
  string s; cin >> s;
  int K; cin >> K;
  int n=s.size();
  dp[0][0][0]=1;
  rep(i,n)rep(j,K+1)rep(k,2){
    int nd=s[i]-'0';
    rep(d,10){
      int ni=i+1,nj=j,nk=k;
      if(k==0){
        if(d>nd) continue;
        if(d<nd) nk=1;
      }
      if(d!=0) nj++;
      if(nj>K) continue;
      dp[ni][nj][nk]+=dp[i][j][k];
    }
  }
  cout << dp[n][K][0]+dp[n][K][1] << endl;
}

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

int main(void){
    int n;
    int i;
    int ans = 1;
    int max = 0;
    int cnt;
    int x;
    
    cin >> n;
    
    for(i = 1; i <= n; i++){
        cnt = 0;
        if(i % 2 == 0){
            x = i;
            while(x % 2 == 0 && x > 1){
                x = x / 2;
                cnt++;
            }
            if(cnt > max){
                max = cnt;
                ans = i;
            }
        }
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
main :: IO ()
main = do
    str <- getLine
    let inputs = [read word :: Int | word <- words str]
    let a = head inputs
    let b = head $ tail inputs
    let c = head $ tail $ tail inputs

    putStrLn $ ans a b c

ans :: Int -> Int -> Int -> String
ans a b c
    | a < b && b < c = "Yes"
    | otherwise = "No"

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

int main()
{
    int n,m;
    cin >> n >> m;
    int a[10000];
    int sum = 0;
    for( int i = 0; i < m; i++ )
    {
        cin >> a[i];
        sum = sum + a[i];
    }

    if( sum <= n )
    {
        cout << n - sum << endl;
    }
    else{
        cout << -1 << endl;
    }
    return 0;
}



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

int main() {
  double n,k; cin>>n>>k;
  double ans=0;
  // kの何分の1以上の範囲を示す
  double denom = 1;
  // 出た目がk以上ならば、無条件で勝利
  // そうでないときはコインを振る
  // k/2より大きい最小の整数~k-1までは,1/2の確率で勝つ
  // k/4より...と続ける？
  for(double i=n; i>=1; i--) {
    while(i<k/denom) denom*=2;
    ans+=1.0/(n*denom);
  }
  cout << fixed << setprecision(12) << ans << endl;
}


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

using namespace std;

int n, h[100000], dp[100001];

int main(){
	memset(dp, INT_MAX, sizeof(dp));
	cin >> n;
	for(int i = 0; i < n; ++i) cin >> h[i];
	dp[0] = 0; dp[1] = abs(h[0] - h[1]);
	
	for(int i = 2; i < n; ++i){
		dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
	}
	
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
//#define DEBUG
#include <cstdio>

using namespace std;

const int maxn=200000, maxa=1000000000;

int min(int a, int b) {
  return a<b ? a : b;
}

bool add(int &n, int num[][2], int size) {
  if (n==0) {
    return false;
  } else if (num[n][1]==size) {
    int t=num[n][0];
    n--;
    if (add(n, num, size)) {
      num[++n][0] = t;
      num[n][1] = 1;
    } else {
      return false;
    }
  } else {
    int t=num[n][1]+1;
    num[n][0]--;
    if (!num[n][0]) {
      n--;
    }
    num[++n][0] = 1;
    num[n][1] = t;
  }
  return true;
}

bool check(int n, int a[], int size) {
  static int str[maxn+1][2];
  int len=0;
  for (int i=1; i<=n; i++) {
    if (a[i]>a[i-1]) {
      if (str[len][1]!=1) {
        str[++len][1] = 1;
        str[len][0] = 0;
      }
      str[len][0] += a[i]-a[i-1];
    } else if (a[i]<=a[i-1]) {
      int off=a[i-1]-a[i];
      for (; off; ) {
        int t=min(off, str[len][0]);
        str[len][0]-=t, off-=t;
        if (!str[len][0]) {
          len--;
        }
      }
      if (!add(len, str, size)) {
        return false;
      }
    }
  }
  return true;
}

int main() {
#ifdef DEBUG
  freopen("src.in", "r", stdin);
  freopen("src.out", "w", stdout);
#endif

  static int a[maxn+1];
  int n;
  scanf("%d", &n);
  for (int i=1; i<=n; i++) {
    scanf("%d", a+i);
  }

  int ans;
  for (int l=1, r=n, mid; l<=r; ) {
    mid = (l+r)/2;
    if (check(n, a, mid)) {
      r = mid-1;
      ans = mid;
    } else {
      l = mid+1;
    }
  }
  printf("%d", ans);

  fclose(stdin);
  fclose(stdout);
  return 0;
}


Measured memory_bytes: 2488
#include <iostream>
// #include <cstdint>
#include <boost/multiprecision/cpp_dec_float.hpp>

int main()
{
    boost::multiprecision::cpp_dec_float_50 a, b;
    std::cin >> a >> b;
    std::cout << llround(floor(a * b)) << std::endl;
    // (std::int64_t)floor(a * b) doesn't work :(
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
char p[101000];
int s[101000],P[101000],n;
int main()
{
    scanf("%d",&n);
    scanf("%s",&p);
    int i,j;
    for(i=0;p[i];i++)
    {
    	if(p[i]=='o') P[i+1]=0;
    	else P[i+1]=1;
	}
	P[n+1]=P[1];
	for(i=0;i<8;i++)
	{
		s[0]=i&1;
		s[1]=(i>>1)&1;
		s[2]=(i>>2)&1;
        for(j=2;j<=n+1;j++)
		{
			s[j+1]=s[j-2]^P[j];
		}/*
		cout<<"i:  ";
		for(int i=0;i<=n+2;i++)
		{
			cout<<i<<" ";
		}
		cout<<endl;
		cout<<"P:  ";
		for(int i=0;i<=n+2;i++)
		{
			cout<<P[i]<<" ";
		}
		cout<<endl;
		cout<<"s:  ";
		for(int i=0;i<=n+2;i++)
		{
			cout<<s[i]<<" ";
		}
		cout<<endl;
		cout<<endl;*/
        if(s[0]^s[n]^s[1]^s[n+1]||s[1]^s[n+1]^s[2]^s[n+2]) continue;
        for(j=1;j<=n;j++)
        {
        	printf("%c",(s[j-1]^s[j])?'W':'S');
		}
//		cout<<endl;
		return 0;
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 1280
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()    
    #define bit(n) (1LL<<(n))
    template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
    template<class T> inline bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
#pragma endregion library

int main(){
    string s; cin >> s;
    int cnt = 0;
    rep(i,3){
        if(s[i]=='R') cnt++;
    }
    if(s[1]=='S' && cnt==2) cnt--;
    cout << cnt << '\n';
    
}


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

int main(){
    ll n;
    cin>>n;
    cout << (n-1)*n/2<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		for(int i=0; i<n; i++) a[i] = sc.nextInt();
		Arrays.sort(a);
		long max = a[n-1];
		int l = 0;
		int r = n-1;
		while(Math.abs(l-r)>1) {
			int mid = (l+r)/2;
			if(max>2*a[mid]+1) {
				l = mid;
			} else {
				r = mid;
			}
		}
		if(l+1<n-1) {
			if(Math.abs(max-2*a[l]-1)<Math.abs(max-2*a[l+1]-1)) {
				System.out.println(max + " " + a[l]);	
			} else {
				System.out.println(max + " " + a[l+1]);
			}
		} else {
			System.out.println(max + " " + a[l]);	
		}
	}

	static class MyScanner
	{
		BufferedReader br;
		StringTokenizer st;
		public MyScanner(InputStream s)
		{
			br=new BufferedReader(new InputStreamReader(s));
		}
		public String nextLine() throws IOException
		{
			return br.readLine();
		}
		public String next() throws IOException
		{
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException
		{
			return Integer.parseInt(next());
			
		}
		public double nextDouble() throws IOException
		{
			return Double.parseDouble(next());
		}
		public boolean ready() throws IOException
		{
			return br.ready();
		}
		public long nextLong() throws IOException
		{
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 36224
#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 ld long double
#define pp pair<ll,ll>
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define sz(a) int((a).size())
#define hell 1000000007
#define f first
#define s second
#define sll(x) scanf("%lld",&x)
#define si(x) scanf("%d",&x)
typedef tree<ll , null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update > ordered_set ;
ll t = 1 ;
void solve()
{
    string s ;
    cin >> s ;
    rep( i , 0 , sz(s))
    {
        rep( j , i , sz(s) )
        {
            string ss = "" ;
            rep( k , 0 , sz(s) )
                if(k>=i&&k<=j);
                else
                    ss+=s[k];
            if(ss=="keyence"||s=="keyence")
            {
                cout << "YES";return;
            }
        }
    }
    cout << "NO";
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   // cin>>t;
    while(t--)
        solve() ;
    return 0 ;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int h,m,s,a,S;
	scanf("%d",&S);
	h=S/3600;
	a=S-(h*3600);
	m=a/60;
	s=a-(m*60);
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 1024
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		for (int i = 1; i < 10 ; i++) {
			for (int j = 1; j < 10; j++)
			{
				System.out.println(i + "x" + j + "=" + i*j);
			}
		}


	}

}

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


int gcd(int a, int b){
    while(b){
        int temp = a % b;
        a = b;
        b = temp;
    }

    return a;
}

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

    int a[100100], dp[100100], dp1[100100];
    for (int i = 0; i < n; i++)
        cin >> a[i];

    dp[0] = a[0];
    dp1[n - 1] = a[n - 1];
    for (int i = 1; i < n; i++)
        dp[i] = gcd(dp[i - 1], a[i]);

    for (int i = n - 2; i >= 0; i--)
        dp1[i] = gcd(dp1[i + 1], a[i]);

    int ans = 1;
    for (int i = 1; i < n - 1; i++){
        ans = max(ans, gcd(dp[i - 1], dp1[i + 1]));
    }


    ans = max(ans, dp1[1]);
    ans = max(ans, dp[n - 2]);

    cout << ans << '\n';

    return 0;
}



Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B___Product_Max
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var input = Console.ReadLine().Split(' ');
                long a = long.Parse(input[0]);
                long b = long.Parse(input[1]);
                long c = long.Parse(input[2]);
                long d = long.Parse(input[3]);


                var result = Math.Max(Math.Max(a * c, a * d), Math.Max(b * c, b * d));




                Console.WriteLine(result);
                break;

            }
        }
    }
}


Measured memory_bytes: 27440
#include <bits/stdc++.h>
using namespace std;
vector<long long>v[300000];
long long vis[300000],sum;
void dfs(int node)
{
    vis[node]=1;
    sum++;
    for(int i=0;i<v[node].size();i++)
    {
        if(vis[v[node][i]]==0)
        dfs(v[node][i]);
    }
}
int main() {
	
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
   
      long long n,i,j,k,count=0,ans=0,x=0,y=0,l,r,m;
      cin>>n>>m;
      if(m==0)
      {
          cout<<1; return 0;
      }
      long long a[m],b[m];
      for(i=0;i<m;i++)
      {
          cin>>a[i]>>b[i];
          a[i]--;
          b[i]--;
          v[a[i]].push_back(b[i]);
          v[b[i]].push_back(a[i]);   
      }
      ans=0;
      for(i=0;i<n;i++)
      {
          sum=0;
          if(vis[i]==0)
          dfs(i);
          ans=max(ans,sum);
      }
      cout<<ans;
    
	return 0;
}

Measured memory_bytes: 27784
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>    
#define inf 100000000
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
long long mod=(long long)1e09+7;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct
int main(void){
    int n,p,i,j,w,c[50];
    while(1){
        n=in();
        p=in();
        if(!n)break;
        i=0;
        w=p;
        MEMSET(c);
        while(1){
            if(w){
                w--;
                c[i%n]++;
                if(!w){
                    rep(j,n){
                        if(j==i%n)continue;
                        if(c[j])break;
                    }
                    if(j==n){
                        print(i%n);
                        break;
                    }
                }
            }
            else{
                w+=c[i%n];
                c[i%n]=0;
            }
            i++;
        }
    }
    return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 2;

void solve() {
    ll n; cin >> n;
    string s; cin >> s;
    vector<int> r(n+1), g(n+1), b(n+1);
    for (int i = 0; i < n; ++i) {
        r[i+1] = r[i];
        g[i+1] = g[i];
        b[i+1] = b[i];
        if(s[i]=='R') ++r[i+1];
        if(s[i]=='G') ++g[i+1];
        if(s[i]=='B') ++b[i+1];
    }

    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            if(s[i] == s[j]) continue;

            int d = j-i;

            if(s[i]=='R'){
                if(s[j]=='G'){
                    ans += b[n] - b[j];
                    if(j + d < n && s[j+d]=='B'){
                        --ans;
                    }
                }
                else if (s[j]=='B'){
                    ans += g[n] - g[j];
                    if(j + d < n && s[j+d]=='G') --ans;
                }
            }
            if(s[i]=='G'){
                if(s[j]=='R'){
                    ans += b[n] - b[j];
                    if(j + d < n && s[j+d]=='B') --ans;
                }
                else if (s[j]=='B'){
                    ans += r[n] - r[j];
                    if(j + d < n && s[j+d]=='R') --ans;
                }
            }
            if(s[i]=='B'){
                if(s[j]=='R'){
                    ans += g[n]- g[j];
                    if(j + d < n && s[j+d]=='G') --ans;
                }
                else if (s[j]=='G'){
                    ans += r[n]- r[j];
                    if(j + d < n && s[j+d]=='R') --ans;
                }
            }
        }
    }
    cout << ans << endl;


}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 3688
use std::io::stdin;

fn main() {
    let mut n = String::new();
    stdin().read_line(&mut n).unwrap();
    let n: isize = n.trim().parse().unwrap();
    let res = c(n);
    println!("{}", if res.is_empty() { "0".to_string() } else { res });
}

fn c(n: isize) -> String {
    match n {
        0 => "".into(),
        x if x % 2 != 0 => format!("{}1", c((n - 1) / -2)),
        _ => format!("{}0", c(n / -2)),
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define INF 100000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N;
  cin >> N;
  vector<ll> A(N);
  vector<pll> a_ind(N);//a, index
  for (ll i = 0; i < N; ++i) {
    cin >> A.at(i);
    a_ind.at(i) = {A.at(i), i};
  }
  sort(a_ind.begin(), a_ind.end(), [] (pll a, pll b){
    return a.first > b.first;
  });
  vector<vector<ll>> dp(N + 2, vector<ll>(N + 2, 0));
  for (ll i = 1; i <= N; ++i) {
    for (ll left = 0; left <= i; ++left) {
      ll right = N - (i - left) + 1;
      // cout << "l" << left << "r" << right << endl;
      // cout << "ind" << a_ind.at(i - 1).second << endl;
      ll temp = dp.at(left).at(right);
      if (left != 0) {
        temp = max(temp, dp.at(left - 1).at(right) + a_ind.at(i - 1).first * abs(left - 1 - a_ind.at(i - 1).second));
      }
      if (right != N + 1) {
        temp = max(temp, dp.at(left).at(right + 1) + a_ind.at(i - 1).first * abs(right - 1 - a_ind.at(i - 1).second));
      }
      dp.at(left).at(right) = temp;
      // cout << temp << endl;
    }
  }
  ll ans = 0;
  for (ll i = 0; i < N; ++i) {
    ans = max(ans, dp.at(i).at(i + 1));
  }
  cout << ans << endl;
  // for (ll i = 0; i < N + 2; ++i) {
  //   for (ll j = 0; j < N + 2; ++j) {
  //     cout << dp.at(i).at(j) << ' ';
  //   }
  //   cout << endl;
  // }
}


Measured memory_bytes: 34588
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

 
int main(){
  int a,b,c;
  cin >> a >> b >> c;

  if(a<=c && c<=b){ cout << "Yes" << endl; return 0; }

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

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int[] a = sc.nextIntList(N);

		long ret = Long.MAX_VALUE;

		for (int k = -100; k <= 100; k++) {
			long now = 0;
			for (int x : a) {
				now += (k - x) * (k - x);
			}
			ret = Math.min(ret, now);
		}
		System.out.println(ret);
	}

}

class FastScanner {
	public static String debug = null;

	private final InputStream in = System.in;
	private int ptr = 0;
	private int buflen = 0;
	private byte[] buffer = new byte[1024];
	private boolean eos = false;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				if (debug != null) {
					buflen = debug.length();
					buffer = debug.getBytes();
					debug = "";
					eos = true;
				} else {
					buflen = in.read(buffer);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen < 0) {
				eos = true;
				return false;
			} else if (buflen == 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean isEOS() {
		return this.eos;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public long[] nextLongList(int n) {
		return nextLongTable(1, n)[0];
	}

	public int[] nextIntList(int n) {
		return nextIntTable(1, n)[0];
	}

	public long[][] nextLongTable(int n, int m) {
		long[][] ret = new long[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				ret[i][j] = nextLong();
			}
		}
		return ret;
	}

	public int[][] nextIntTable(int n, int m) {
		int[][] ret = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				ret[i][j] = nextInt();
			}
		}
		return ret;
	}
}

Measured memory_bytes: 7892
#include<iostream>
#define int long long
using namespace std;
int n,cnt;
inline int f(int s,int a,int b,int c){
    if(s>n)return 0;
    if(a&&b&&c)cnt++;
    f(s*10+3,1,b,c);
    f(s*10+5,a,1,c);
    f(s*10+7,a,b,1);
}
main(){
    cin>>n;
    f(0,0,0,0);
    cout<<cnt<<endl;
}

Measured memory_bytes: 256