akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
            int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();
            if(op.equals("?"))  break;
            if(op.equals("+"))  System.out.println( a + b );
            if(op.equals("-"))  System.out.println( a - b );
            if(op.equals("*"))  System.out.println( a * b );
            if(op.equals("/"))  System.out.println( a / b );
        }
    }
}


Measured memory_bytes: 26232
from math import sqrt

c1x, c1y, c1r = map(int, input().split())
c2x, c2y, c2r = map(int, input().split())
d = sqrt((c2x - c1x) ** 2 + (c2y - c1y) ** 2)
sr, dr = c1r + c2r, abs(c1r - c2r)
eps = 1e-6
if d - sr > eps:
    print(4)
elif abs(d - sr) < eps:
    print(3)
elif d - dr > eps:
    print(2)
elif abs(d - dr) < eps:
    print(1)
else:
    print(0)

Measured memory_bytes: 7756
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
bool toolgates[200];
int costToZero(int n, int x ){
	int cost = 0;
	for(int i=0; i<x; i++){
		if (toolgates[i]){
			cost++;
		}
	}
	return cost;
}
int costToN(int n, int x){
	int cost = 0;
	for (int i =x; i<n; i++ ){
		if (toolgates[i]){
			cost++;
		}
	}
	return cost;
}
int main() {
	// your code goes here
	int n=0; int x=0; int m=0;
	scanf("%d", &n);
	scanf("%d", &m);
	scanf("%d", &x);
	for(int i = 0; i <m; i++){
		int temp = 0;
		scanf("%d", &temp);
		toolgates[temp] = true;
	}
	
	printf("%d", min(costToZero(n, x), costToN(n,x)));
 
}
 

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

#define inf 0x3f3f3f3f
#define INF 1000111000111000111LL
#define mod 1000000007
#define endl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fi first
#define se second
#define all(cc) (cc).begin(),(cc).end()
using lli = long long int ;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vb = vector<bool> ;
using vvi = vector<vector<int>> ;
using vlli = vector<long long int> ;
using vpii = vector<pair<int, int>> ;

int main()
  {
    ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
    int n, ans=0, res=0 ;
    cin>> n ;
    vi a(n), b ;
    for(int i=0 ; i<n ; i++)
      cin>> a[i] ;
    for(int i=0 ; i<n ; i++)
      if(a[i]%10==0) ans+=a[i] ;
      else b.pb(a[i]) ;
    sort(all(b)) ;
    reverse(all(b)) ;
    for(int i=0 ; i<b.size() ; i++)
      {
        ans+=b[i] ;
        if(ans%10) res=max(ans, res) ;
      }
    cout<< res ;
  }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)

struct edge {int to, dist, c;} ;

typedef pair<int, int> pii;
typedef pair<int, pii> pi3;
typedef pair<double, pi3> P; // time, vertex, from, velocity

int main() {
    while(true) {
        int n, m;
        cin >> n >> m;
        if (n==0) break;

        int s, g;
        cin >> s >> g;

        double time[40][40][40]; // vertex, velocity, from
        REP(i, n) {
            REP(j, 31) {
                REP(k, n) {
                    time[i][j][k] = 1000000000;
                }
            }
        }
        time[s-1][0][s-1] = 0;

        vector<edge> gr[40];
        REP(i, m) {
            int x, y, d, c;
            cin >> x >> y >> d >> c;
            
            edge e1;
            e1.to = y-1;
            e1.dist = d;
            e1.c = c;
            gr[x-1].push_back(e1);

            edge e2;
            e2.to = x-1;
            e2.dist = d;
            e2.c = c;
            gr[y-1].push_back(e2);
        }

        priority_queue<P, vector<P>, greater<P>> que;
        P q = P(0.0, pi3(s-1, pii(s-1, 0)));
        que.push(q);

        while(!que.empty()) {
            P q = que.top(); que.pop();
            double t = q.first;
            int v = q.second.first;
            int from = q.second.second.first;
            int velo = q.second.second.second;
            if (time[v][velo][from] < t) continue;

            REP(i, gr[v].size()) {
                if (gr[v][i].to == from) continue; // u-turn
                REP(a, 3) {
                    int accel = a-1;
                    if(velo+accel <= 0 || velo+accel > gr[v][i].c) continue;

                    if (time[gr[v][i].to][velo+accel][v] >
                            time[v][velo][from] + (double)gr[v][i].dist / (double)(velo+accel)){
                        time[gr[v][i].to][velo+accel][v]= 
                            time[v][velo][from] + (double)gr[v][i].dist / (double)(velo+accel);
                        
                        P q = P(time[gr[v][i].to][velo+accel][v],
                                pi3(gr[v][i].to, pii(v, velo+accel)));
                        que.push(q);
                    }
                }
            }
        }
        
        double output = 1000000000;
        REP(i, n) {
            output = min(time[g-1][1][i], output);
        }

        if (output == 1000000000) {
            cout << "unreachable" << endl;
        } else {
            printf("%.10lf\n", output);
        }
    }
}



Measured memory_bytes: 3924
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include <functional>
#include <limits>


using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

class BIT{
	vector<int> bit;
	
public:
	
	BIT(){
	}
	
	BIT(int size){
		init(size);
	}
	
	void init(int size){
		bit.clear();
		bit.resize(size+1);
	}
	
	int sum(int i){
		int s = 0;
		while(i > 0){
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}

	void add(int i , int x){
		while(i < bit.size()){
			bit[i] += x;
			i += i & -i;
		}
	}

	int lower_bound(int w){
		if(w <= 0) return 0;
		int x = 0, t = 1;
		while(t*2 < bit.size()) t *= 2;
		
		for(int k = t; k > 0; k /= 2){
			if(x + k < bit.size() && bit[x + k] < w){
				w -= bit[x + k];
				x += k;
			}
		}
		return x + 1;
	}
};

struct fast_io {
	fast_io(){
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	// cout<<fixed<<setprecision(10);
	
	int N, Q;
	string S;
	vector<BIT> bit(26);
	
	cin>>N;
	cin>>S;
	cin>>Q;
	
	for(int i = 0; i < 26; i++){
		bit[i].init(N+10);
	}
	
	for(int i = 0; i < N; i++){
		bit[S[i] - 'a'].add(i+1, 1);
	}
	
	for(int i = 0; i < Q; i++){
		int a, b;
		
		cin>>a>>b;
		
		
		if(a == 1) {
			char c;
			
			cin>>c;
			
			bit[S[b-1] - 'a'].add(b, -1);
			bit[c - 'a'].add(b, 1);
			S[b-1] = c;
			
		} else {
			int r;
			cin>>r;
			
			int con = 0;
			for(int j = 0; j < 26; j++){
				if(bit[j].sum(r) - bit[j].sum(b-1) >= 1) con++;
			}
			
			cout<<con<<endl;
		}
	}
	
	return 0;
}

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

using namespace std;

int main(void){
    string grade;
    cin>>grade;
    int maru = 0;
    int batsu = 0;
    for(int i=0; i<16; i++){
        if(grade[i]=='o')maru++;
        else if(grade[i]=='x')batsu++;
        else break;
    }

    if(8-maru <= 15-(maru+batsu))cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io
	int a,p; cin>>a>>p;
	cout<<((3*a+p)/2);
	return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
A = LIST()

# if N <= K:
# 	print(1)
# else:
# 	print(ceil((N-K)/(K-1)) + 1)
print(ceil((N-K)/(K-1)) + 1)

Measured memory_bytes: 14504
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		print(n == m ? "Yes" : "No");
		sc.close();
	}

	public static void print(Object obj) {
		System.out.println(obj);
	}

}

Measured memory_bytes: 22996
from collections import deque

N = int(input())

L = [[] for i in range(N)]

for i in range(N-1) :
    a,b,c = map(int,input().split())
    a -= 1
    b -= 1
    L[a].append([b,c])
    L[b].append([a,c])
    

Q,K = map(int,input().split())

K -= 1

DISTANCE = [float("inf") for i in range(N)]

DISTANCE[K] = 0

q = deque([K])

while q :
    from_ = q.popleft()
    for to_, weight in L[from_] :
        dist = DISTANCE[from_] + weight
        if dist < DISTANCE[to_] :
            DISTANCE[to_] = dist
            q.append(to_)
            
ans = []

for i in range(Q) :
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    
    calc = DISTANCE[x] + DISTANCE[y]
    ans.append(calc)

print(*ans, sep="\n")


Measured memory_bytes: 106144
n=int(input())
a=[0]+list(map(int,input().split()))
d=[[] for _ in range(n+1)]
p=[0]*(n+1)
for i in range(1,n+1):
  for j in range(i,n+1,i):
    d[j]+=[i]
ans=[]
for i in range(n,0,-1):
  if a[i]!=p[i]:
    ans+=[i]
    for j in d[i]:
      p[j]=1-p[j]
  else:p[i]=0
print(len(ans))
print(*ans)

Measured memory_bytes: 167748
#include <queue>
#include <iostream>

using namespace std;

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
typedef pair<int, int> ii;


int f(int k,int t,int *c){
	int res = 0;
	priority_queue<ii> q;
	FOR(i,0,t){
        ii p;
        p.first = c[i];
        p.second = i;
        q.push(p);
    }
    int last = -1;
    while(q.size()>1){
        ii p = q.top(); q.pop();
        if(p.second == last){
            if(q.empty()) break;
            ii next = q.top(); q.pop();
            res += 2;
            next.first --;
            p.first --;
            if(p.first){
            	q.push(p);
            }
            if(next.first){
            	q.push(next);
            }
        }else{
            res += 1;
            last = p.second;
            p.first --;
            if(p.first){
            	q.push(p);
            }
        }
    }
    res = k - res;
   if(q.size() == 1){
   		ii p = q.top(); 
   		if(last != p.second) res -= 1;
   }
   return res;
}

int main(int argc, char *argv[]){
    int k;
    int t;
    while(cin>>k>>t){
    	int c[50000+5];
        int res = 0;
        priority_queue<ii> q;
        FOR(i,0,t){
            cin>>c[i];
        }
        cout<<f(k,t,c)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int H,A[MAX+1];

void maxHeapify(int i){
    int l,r,largest;
    l=2*i;
    r=2*i+1;

    //????????????????????????????????????????????????????????§?????????
    if(l<=H&&A[l]>A[i])
        largest=l;
    else
        largest=i;
    if(r<=H&&A[r]>A[largest])
        largest=r;

    if(largest!=i){
        swap(A[i],A[largest]);
        maxHeapify(largest);
    }
}

int extract(){
    int maxv;
    if(H<1)
        return -INFTY;
    maxv=A[1];
    A[1]=A[H--];
    maxHeapify(1);
    return maxv;
}

void increaseKey(int i,int key){
    if(key<A[i])
        return;
    A[i]=key;
    while(i>1&&A[i/2]<A[i]){
        swap(A[i],A[i/2]);
        i/=2;
    }
}

void insert(int key){
    H++;
    A[H]=-INFTY;
    increaseKey(H,key);
}

int main(){
    int key;
    char com[10];

    while(~scanf("%s",com)&&(com[0]!='e'||com[1]!='n')){
        if(com[0]=='i'){
            scanf("%d",&key);
            insert(key);
        } else
            printf("%d\n",extract());
    }
}

Measured memory_bytes: 6592
#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
	cin >> s;
	int cnt = 1;
	char t=s[0];
	for(int i=1;;){
		if(s[i]==t){
			i+=2;
			t=' ';	
		}
		else{
			t=s[i];
			i++;
		}
		if(i>s.size()) break;	
		cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 640
# coding: utf-8
# Your code here!

from collections import deque
from pprint import pprint
moves=[(0,1),(1,0),(0,-1),(-1,0)]
pp=pprint
# INF=float("inf")

h,w,k=map(int,input().split())
x1,y1,x2,y2=map(lambda x:int(x)-1,input().split())
maze=[list(input()) for _ in range(h)]
cost=[[-1]*w for _ in range(h)]

todo=deque()
todo.append((x1,y1))
cost[x1][y1]=0

while todo:
    x,y=todo.popleft()
    for vx,vy in moves:
        for kk in range(1,k+1):
            nx=x+vx*kk
            ny=y+vy*kk
            if not(0<=nx<h) or not(0<=ny<w):
                continue
            if maze[nx][ny]=="@":
                break
            if cost[nx][ny]!=-1 and cost[nx][ny]<=cost[x][y]:
                break
            if cost[nx][ny]!=-1:
                continue
            cost[nx][ny]=cost[x][y]+1
            todo.append((nx,ny))


# pp(cost)
ans=cost[x2][y2]
print(ans)

Measured memory_bytes: 139772
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial, ceil, floor
from collections import defaultdict
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, M, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

N, = map(int, input().split())
L = [int(v) for v in input().split()]
L.sort()

# only + 2
# only - 1
# + - 3
c = 0
for v in L:
    if v < 0:
        c = c | 1
    elif v > 0:
        c = c | 2

if c == 0:
    c = 2

if c == 2:
    if N == 2:
        print(max(L) - min(L))
        print(max(L), min(L))
        exit()

    ans = []
    p = L[0] - L[-1]
    ans.append((L[0], L[-1]))
    for v in L[1:-2]:
        ans.append((p, v))
        p -= v
    ans.append((L[-2], p))
    print(L[-2] - p)
    for x, y in ans:
        print(x, y)

if c == 1:
    if N == 2:
        print(max(L) - min(L))
        print(max(L), min(L))
        exit()

    ans = []
    p = L[-1] - L[0]
    ans.append((L[-1], L[0]))
    for v in L[1:-2]:
        ans.append((p, v))
        p -= v
    ans.append((p, L[-2]))
    print(p - L[-2])
    for x, y in ans:
        print(x, y)

if c == 3:
    if N == 2:
        print(max(L) - min(L))
        print(max(L), min(L))
        exit()

    mc = 0
    for v in L:
        if v < 0:
            mc += 1

    ans = []
    if N - mc == 1:
        p = L[-1] - L[0]
        ans.append((L[-1], L[0]))
        for v in L[1:-1]:
            ans.append((p, v))
            p -= v
        print(p)
        for x, y in ans:
            print(x, y)

        exit()

    ans = []
    p = L[0] - L[-1]
    ans.append((L[0], L[-1]))
    for v in L[mc:-2]:
        ans.append((p, v))
        p -= v
    ans.append((L[-2], p))
    p = L[-2] - p
    for v in L[1:mc]:
        ans.append((p, v))
        p -= v
    print(p)
    for x, y in ans:
        print(x, y)

Measured memory_bytes: 20508
#include <iostream>

#include<vector>

#include<string>

#include<algorithm>

#include<cmath>

#include<cstdlib>

#include<utility> 

#include<cstdio> 

#define vii vector< pair<int,int> >

#define vi vector<int>

#define INF 1000000007

#define ff first

#define ss second

#define lli long long int

#define ulli unsigned long long int

using namespace std;

int main() {

 ios_base::sync_with_stdio(false);

    cin.tie(NULL);
     int n;
     cin>>n;
     cout<<(n^1)<<endl;
 

}

Measured memory_bytes: 3636
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

#define MAX_N 1000000007
#define INF 100000000000000

int main(){
  string s,t;
  cin >> s >> t;
  int r[26];
  int ri[26];
  bool flag = true;
  for(int i=0;i<26;i++){
    r[i] = -1;
    ri[i] = -1;
  }
  for(int i=0;i<s.length();i++){
    int si = s[i]-'a';
    int ti = t[i]-'a';
    if(r[si] < 0) r[si]=ti;
    else if(r[si] != ti){
      flag = false;
      break;
    }
    if(ri[ti] < 0) ri[ti]=si;
    else if(ri[ti] != si){
      flag = false;
      break;
    }
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;


  return 0;
}


Measured memory_bytes: 776
N,M = map(int,input().split())
A = []

#フィボナッチ数列
def Fib(n):
    a, b = 1, 1
    if n == 0:
        return 0
    elif n== 1:
        return 1
    elif n == 2:
        return 1
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b
 
for i in range(M):
  a = int(input())
  A.append(a)
#ans = {0~a1-1 a1+1~a2-1 ... a(M-1)+1~aM-1 の行き方の積}
#各a(i)+1~a(i+1)-1への行き方は1通り
#i ~ i+Nへの行き方 Fib(N+1)通り

#REになっていた理由:
#・Fib(0)が定義されていなかったから
#・フィボナッチ数列を再帰的(=Fib(n-1)+Fib(n-2))で定義していると、
#Nが大きい(100000とか）のときに深く潜りすぎるのでRE

if(N == 1): 
 ans = 1
elif(M == 0): 
 ans = Fib(N+1)
else: 
 ans = 0
 for i in range(M):  
    if(i == 0): #0~ a1-1 // ai+1 = A[i]
      n = (A[i]-1)-0
      #print(0,A[i]-1)
    else:
      n = (A[i]-1)-(A[i-1]+1) 
      #print(A[i-1]+1,A[i]-1)
      
    if(i != 0): #「渡れない箇所が二連続」が存在するなら0通り
     dif = A[i]-A[i-1]
     if(dif == 1):
       ans = 0
       break
          
    if(ans == 0): ans += (Fib(n+1)%(10**9 + 7))
    else: ans = ans*(Fib(n+1)%(10**9 + 7))

 n = N - (A[M-1]+1)#最後にaM + 1 ~ N のルートも考慮する
 ans = ans*(Fib(n+1)%(10**9 + 7))
 #print(A[M-1]+1,N)
            
ans = ans%(10**9 + 7)
print(ans)  

Measured memory_bytes: 7076
//#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;

const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 97;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x){
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

// OrderedSet
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template < typename T > using ordered_set = tree < T, null_type, greater < T >, rb_tree_tag, tree_order_statistics_node_update >;

//typedef uint64_t hash_t;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//const int HASH_COUNT = 2;
//const hash_t HASH_P = (uint32_t)-13337;
//uniform_int_distribution<hash_t> MULT_DIST(0.25 * HASH_P, 0.75 * HASH_P);
//const hash_t HASH_MULT[HASH_COUNT] = {MULT_DIST(rng), MULT_DIST(rng)};


int main(){
  int n, m, sum = 0;
  fastScan(n);
  fastScan(m);
  for(int i = 0; i < m; i++){
    int x;
    fastScan(x);
    sum += x;
  }
  puts(sum >= n ? "Yes" : "No");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[200005];
inline bool check(const int &k){
    if((a[n-1]<=k&&a[n]<=k)||(a[n]<=k&&a[n+1]<=k))return 1;
    if((a[n-1]> k&&a[n]> k)||(a[n]> k&&a[n+1]> k))return 0;
    for(int i=1;i<n-1;i++){
        if((a[n+i]<=k&&a[n+i+1]<=k)||(a[n-i]<=k&&a[n-i-1]<=k))return 1;
        if((a[n+i]> k&&a[n+i+1]> k)||(a[n-i]> k&&a[n-i-1]> k))return 0;}
    return a[1]<=k;}
int main(){
    scanf("%d",&n);
    for(int i=1;i<n<<1;i++)scanf("%d",a+i);
    int l=1,r=(n<<1)-1;
    while(l<r){
        int mid=l+r>>1;
        if(check(mid))r=mid;
        else l=mid+1;}
    printf("%d",l);
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define f(i,a,b) for(int i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define all(a) a.begin(),a.end()
#define size(s) s.size()
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using si = stack<LL>;
using pi = pair<LL, LL>;
using v_pi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b) f(i,0,n){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

/*****************************************************************************/


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

	st s, t;
	cin >> s >> t;
	map<char, char>ms, mt;
	f(i, 0, size(s)) {
		char c = t[i];
		if (ms[s[i]] == c)continue;
		if (ms[s[i]] == 0) {
			ms[s[i]] = t[i];
		}
		else {
			_n();
			return 0;
		}
	}
	f(i, 0, size(t)) {
		char c = s[i];
		if (mt[t[i]] == c)continue;
		if (mt[t[i]] == 0) {
			mt[t[i]] = s[i];
		}
		else {
			_n();
			return 0;
		}
	}
	_y();
	return 0;
}

Measured memory_bytes: 916
n,m=map(int,input().split())
MOD=10**9+7
dp=[0]*(n+1)
breakstair=[False]*(n+1)
a=[]
for i in range(m):
    tmp=int(input())
    breakstair[tmp]=True
dp[0]=1
dp[1]=1
for i in range(2,n+1):
    if breakstair[i-1]:
        if breakstair[i-2]:
            print(0)
            exit()
        dp[i]=dp[i-2]
    elif breakstair[i-2]:
        dp[i]=dp[i-1]
    else:
        dp[i]=(dp[i-1]+dp[i-2])%MOD
print(dp[-1])

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

namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            int[] button = new int[N];
            bool exist2 = false;
            bool[] passed = new bool[N];
            int goto2index = 0;

            for (int i = 0; i < N; i++)
            {
                button[i] = int.Parse(Console.ReadLine()) -1;
                if (button[i] == 1)
                {
                    exist2 = true;
                    goto2index = i;
                }
            }

            if (!exist2)
            {
                Console.WriteLine(-1);
                return;
            }

            int nowIndex = 0;
            int count = 1;
            do
            {
                if (button[nowIndex] == 1)
                {
                    //count++;
                    break;
                }
                else
                {
                    if(passed[nowIndex])
                    {
                        Console.WriteLine(-1);
                        return;
                    }
                    passed[nowIndex] = true;
                    count++;
                    nowIndex = button[nowIndex];
                }
            } while (true);

            Console.WriteLine(count);


            Console.Read();

        }

    }
}


Measured memory_bytes: 15200
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <math.h>
#include <map>
#include <time.h>

using namespace std;

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int a, b;
  string s;
  cin >> a >> b >> s;
  b--;
  if(s[b] == 'A') s[b] = 'a';
  if(s[b] == 'B') s[b] = 'b';
  if(s[b] == 'C') s[b] = 'c';

  cout << s << endl;
}


Measured memory_bytes: 256
using System.Linq;
using static System.Console;
class K
{
int[]G=>ReadLine().Split().Select(i=>int.Parse(i)-1).ToArray();
int N;
static void Main()=>new K().Z();
void Z()
{
var I=G;
N=I[0]+1;
WriteLine(string.Join(" ",C(G,G,I[1]).Select(i=>i+1)));
}
int[]C(int[]p,int[]q,int K)
{
int[]P=I(p),Q=I(q),x=E(M(q,P,Q,p),K/6),y=I(x);
switch(K%6)
{
case 0:return M(x,p,y);
case 1:return M(x,q,y);
case 2:return M(x,q,P,y);
case 3:return M(x,q,P,Q,y);
case 4:return M(x,q,P,Q,p,Q,y);
default:return M(x,q,P,Q,p,p,Q,y);
}
}
int[]I(int[]a)
{
var c=new int[N];
for(var i=0;i<N;i++)c[a[i]]=i;
return c;
}
int[]M(int[]a,int[]b){var p=new int[N];for(var i=0;i<N;i++)p[i]=a[b[i]];return p;}
int[]M(params int[][]a)=>a.Aggregate(M);
int[]E(int[]a,int b)
{
var p=new int[N];
var f=new int[N];
var l=new int[N];
for(var i=0;i<N;i++)
if(f[i]<1)
{
int x=i,C=0;
while(f[x]<1){l[C++]=(x);f[x]=1;x=a[x];}
for(var j=0;j<C;j++)p[l[j]]=l[(j+b)%C];
}
return p;
}
}


Measured memory_bytes: 39508
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

    int n, a;
    cin >> n >> a;

    if(n%500 <= a) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3564
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace DP
{
    using static Ex;
    public class Solve
    {
        public static void Main(string[] args)
        {
            new DP_C();
        }
    }
    public class DP_C
    {
        public DP_C()
        {
            var n = ReadInt;

            var arr = new int[n][];
            for (int i = 0; i < n; i++)
            {
                arr[i] = ReadIntArray();
            }
            var dp = new long[n, 3];
            for (int j = 0; j < 3; j++)
            {
                dp[0, j] = arr[0][j];
            }

            for (int i = 1; i < n; i++)
            {
                dp[i, 0] = Math.Max(dp[i - 1, 1], dp[i - 1, 2]) + arr[i][0];
                dp[i, 1] = Math.Max(dp[i - 1, 0], dp[i - 1, 2]) + arr[i][1];
                dp[i, 2] = Math.Max(dp[i - 1, 0], dp[i - 1, 1]) + arr[i][2];
            }

            var ans = Math.Max(dp[n - 1, 0], dp[n - 1, 1]);
            ans = Math.Max(ans, dp[n - 1, 2]);
            ans.Cw();
        }
    }

    public static class Ex
    {
        public static void Cw(this object s) { Console.WriteLine(s); }



        public static bool Mins<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }
        public static bool Maxs<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
        public static void Swap<T>(ref T a, ref T b) { var t = b; b = a; a = t; }
        public static void Swap<T>(List<T> list, int i, int j) { T tmp = list[j]; list[j] = list[i]; list[i] = tmp; }


        static long Gcd(long m, long n) { if (n == 0) return m; return Gcd(n, m % n); }
        public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.Ordinal); return s.ToList(); }
        public static void yesno(this bool b) { (b ? "yes" : "no").Cw(); }
        public static void YesNo(this bool b) { (b ? "Yes" : "No").Cw(); }
        public static void YESNO(this bool b) { (b ? "YES" : "NO").Cw(); }

        public static string Read { get { return Console.ReadLine().Trim(); } }
        public static int ReadInt { get { return int.Parse(Read); } }
        public static long ReadLong { get { return long.Parse(Read); } }
        public static double ReadDouble { get { return double.Parse(Read); } }
        public static string[] ReadArray() { return Read.Split(' '); }
        public static int[] ReadIntArray() { return Read.Split(' ').Select(int.Parse).ToArray(); }
        public static long[] ReadLongArray() { return Read.Split(' ').Select(long.Parse).ToArray(); }
        public static string[] ReadArray(long N) { var v = new string[N]; for (long i = 0; i < N; ++i) v[i] = Read; return v; }
        public static int[] ReadIntArray(long N) { var v = new int[N]; for (long i = 0; i < N; ++i) v[i] = ReadInt; return v; }
        public static long[] ReadLongArray(long N) { var v = new long[N]; for (long i = 0; i < N; ++i) v[i] = ReadLong; return v; }

    }
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{
  gearup;
  int n,m; cin >> n >> m;
  vector<pair<pair<int,int>,int> > Edge;
  vector<vector<ll> > dp(n+1,vector<ll>(n+1,INF));
    for(int i=0;i<n;i++){
        dp[i][i] = 0;
    }
    for(int i=0;i<m;i++){
        ll a,b,t; cin >> a >> b >> t;
        a--;b--;
        dp[a][b] = t;
        dp[b][a] = t;
        Edge.push_back({{a,b},t});
    }

    //ワーシャルフロイド法
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                chmin(dp[i][j],dp[i][k]+dp[k][j]);
            }
        }
    }
    ll res = 0;
    rep(i,m){
      int a = Edge[i].first.first;
      int b = Edge[i].first.second;
      int t = Edge[i].second;
      if(dp[a][b] != t)res++;
    }
    out(res);
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int x[100100];

const int max_n = 100100;
ll fact[max_n];
void calc_fact() {
    fact[0] = 1;
    for (ll i = 1; i < max_n; i++)
        fact[i] = (fact[i-1] * i) % mod;
}

ll solve() {
    calc_fact();
    ll res = 1;
    int r = 0;
    for (int i = 0; i < n; i++) {
        int t = 2 * r - 1;
        if (x[i] > t+1) {
            r++;
        } else if (x[i] == t+1) {
            res *= (r+1);
            res %= mod;
        }
    }
    res *= fact[r];
    res %= mod;
    return res;
}

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

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int h,w,n,sr,sc;
    cin>>h>>w>>n>>sr>>sc;
    string s,t;
    cin>>s>>t;
    int tr[n+1],tl[n+1],td[n+1],tu[n+1];
    int ar[n+1],al[n+1],ad[n+1],au[n+1];
    tr[0]=tl[0]=td[0]=tu[0]=ar[0]=al[0]=ad[0]=au[0]=0;
    for(int i=0;i<n;i++){
        tr[i+1]=tr[i]+(s[i]=='R');
        tl[i+1]=tl[i]+(s[i]=='L');
        td[i+1]=td[i]+(s[i]=='D');
        tu[i+1]=tu[i]+(s[i]=='U');
        ar[i+1]=ar[i]+(t[i]=='R');
        al[i+1]=al[i]+(t[i]=='L');
        ad[i+1]=ad[i]+(t[i]=='D');
        au[i+1]=au[i]+(t[i]=='U');
        if(sc+tr[i+1]-al[i+1]<=0)al[i+1]=sc+tr[i+1]-1;
        if(sc-tl[i+1]+ar[i+1]>w)ar[i+1]=w-sc+tl[i+1];
        if(sr+td[i+1]-au[i+1]<=0)au[i+1]=sr+td[i+1]-1;
        if(sr-tu[i+1]+ad[i+1]>h)ad[i+1]=h-sr+tu[i+1];
    }
    bool ans=false;
    for(int i=0;i<n;i++){
        if(tr[i+1]-al[i]>=w-sc+1){
            ans=true;
        }
        if(tl[i+1]-ar[i]>=sc){
            ans=true;
        }
        if(td[i+1]-au[i]>=h-sr+1){
            ans=true;
        }
        if(tu[i+1]-ad[i]>=sr){
            ans=true;
        }
    }
    if(ans)cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
}


Measured memory_bytes: 7048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=305,p=998244353,inf=0x3f3f3f3f;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int qpow(int x,int k){
	int t=1;
	for (;k;k>>=1){
		if (k&1) t=(ll)t*x%p;
		x=(ll)x*x%p;
	}
	return t;
}
int n,m,ans,a[N],f[N*N],g[N*N],h[N*N];
void check(int &x,int y){x=(x+y<p) ? (x+y) : (x+y-p);}
int main(){
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	n=read();
	if (n<3){puts("0");return 0;}
	for (int i=1;i<=n;i++) m+=(a[i]=read());
	f[0]=1;g[0]=1;
	for (int i=1;i<=n;i++){
		memcpy(h,f,sizeof(f));
		for (int j=m-a[i];j>=0;j--) {check(g[j+a[i]],g[j]);check(h[j+a[i]],f[j]);}
		for (int j=0;j<=m;j++) check(h[j],f[j]);
		memcpy(f,h,sizeof(f));
	}
	ans=(qpow(3,n)-3ll*qpow(2,n)+3)%p;
	if (ans<0) ans+=p;
	for (int i=1;i<m;i++)
	if (i*2>=m) check(ans,p-3ll*(f[i]-2ll*g[i]+2*p)%p);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.StringTokenizer;

import org.omg.CORBA.PUBLIC_MEMBER;

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();
		StringTokenizer tokenizer;

		int n = Integer.parseInt(reader.readLine());
		for (int i = 0; i < n; i++) {
			String s1 = reader.readLine();
			String s2 = reader.readLine();
			if (s1.length() > 80 && s2.length() > 80) {
				System.out.println("overflow");
			} else {
				BigInteger b1 = new BigInteger(s1);
				BigInteger b2 = new BigInteger(s2);
				String b = String.valueOf(b1.add(b2));
				System.out.println(b.length() > 80 ? "overflow" : b);
			}
		}
	}

}

Measured memory_bytes: 18412
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  
  int score = 0;
  rep(i,n-1) {
    if (s[i] == s[i+1]) score++;
  }

  int ans = min(score+2*k, n-1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include<cstdio>
using namespace std;
#define N 505
int vl[N*3],n,ct,d[4][2]={-1,0,1,0,0,1,0,-1};
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long as[N][N],mx;
int main()
{
	for(int i=501;i<=10000;i++)
	{
		int fg=0;
		for(int j=2;j<=100;j++)if(i%j==0)fg=1;
		if(!fg)vl[++ct]=i;
	}
	for(int i=1;i<=500;i++)as[i][i]=vl[1]*i;
	int st=2;
	for(int i=2;i<=500;i+=2){for(int j=1;i+j<=500;j++)as[i+j][j]=vl[st]*(j+i/2),as[j][i+j]=vl[st+1]*(j+i/2);st+=2;}
	for(int i=1;i<=500;i++)
	for(int j=1;j<=500;j++)
	if((i+j)&1)
	{
		long long st=1;
		for(int s=0;s<4;s++)
		{
			int vl=as[i+d[s][0]][j+d[s][1]];
			if(vl)st=st/gcd(st,vl)*vl;
		}
		as[i][j]=st+1;
		if(mx<st)
		mx=st;
	}
	scanf("%d",&n);
	for(int i=1;i<=n;i++,printf("\n"))
	for(int j=1;j<=n;j++)
	printf("%lld ",as[i][j]);
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

/*
    ここに問題名を入力
*/

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

    if(abs(a-b)<=1){
		cout << "Brown" << endl;
    }else{
		cout << "Alice" << endl;
    }
    return 0;
}
 
 


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vz;
typedef vector<vz> vvz;
typedef pair<ll, ll> pll;
#define sz(x) int((x).size())
#define fo(i,n) for(ll i=0; i<(n); i++)
#define FO(i,a,b) for(ll i=(a); i!=(b); i+=(b)>(a)?1:-1)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(c) c.begin(), c.end()
#define F first
#define S second
#define os(x) cout<<x<<' '
#define on(x) cout<<x<<"\n"
#define nl cout<<"\n"
#define maxe(x) max_element(all(x))-(x).begin()
#define mine(x) min_element(all(x))-(x).begin()

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("C:\\Users\\ASISH\\Desktop\\coding\\input1.txt", "r", stdin);
	freopen("C:\\Users\\ASISH\\Desktop\\coding\\output1.txt", "w", stdout);
#endif

	int tc=1;
	// cin>>tc;
	fo(q, tc)
	{
		ll n, k, t;
		cin>>n>>k>>t;
		on(t*(ll)ceil((double)n/k));
	}
	cerr << "Time : " << ((double)clock()) / (double)CLOCKS_PER_SEC << "s\n";
	return 0;
}

Measured memory_bytes: 3884
fun main(args: Array<String>){
    val (N, C, K) = readLine()!!.split(" ").map { it.toLong() }
    val T = LongArray(N.toInt()){ readLine()!!.toLong() }.sorted().toLongArray()

    var busCount = 0L
    var first = -1L
    var count = 0L
    for(i in T.indices){
        if(first == -1L){
            count++
            first = T[i]
        }else{
            if(first + K >= T[i] && count < C){
                count++
            }else{
                busCount++
                first = T[i]
                count = 1L
            }
        }
    }
    println(busCount + 1)
}

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

int main(){
    int n;
    cin >> n;
    int arr[n];
    int count = 0;
    for(int i=0;i<n;i++){
        cin >> arr[i];
    }
    for(int i=0;i<n;i++){
        int min_i = arr[i];
        int argmin = i;
        for(int j=i+1;j<n;j++){
            if(min_i>arr[j]){
                argmin = j;
                min_i = arr[j];
            }
        }
        if(argmin!=i){
            int tmp = arr[i];
            arr[i] = arr[argmin];
            arr[argmin] = tmp;
            count++;
        }
    }
    for(int i=0;i<n;i++){
        cout << arr[i];
        if(i!=n-1)cout << " ";
    }
    cout << endl << count << endl;
    return 0;
}


Measured memory_bytes: 3088
N = int(input())
A = list(map(int,input().split()))

money = 1000
kabu = 0
for i in range(N):
    today = A[i]
    if i !=N-1:
        tomorrow = A[i+1]
    else:
        tomorrow = 0
    
    if today < tomorrow:
        buy = money//today#できるだけ買う
        money -= today*buy#買った分引く
        kabu += buy
    elif today > tomorrow:
        money += kabu * today
        kabu = 0

print(money)

Measured memory_bytes: 9196
A,B,C,X,Y = map(int,input().split())

minprice = 10 ** 10
XY_max = max(X,Y)

for i in range(XY_max + 1):
    nokori_X = max(X - i,0)
    nokori_Y = max(Y - i,0)

    tmp = i * 2 * C + nokori_X * A + nokori_Y * B
    minprice = min(tmp,minprice)

if minprice == 10 ** 10:
    minprice = 0

print(minprice)

Measured memory_bytes: 3064
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long A = sc.nextLong();
    long B = sc.nextLong();
    long ans = 0;
    for(int i=1; i<=B; i++){
      if((A*i)%B == 0){
        ans = A*i;
        break;
      }
    }
    System.out.print(ans);
  }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#pragma GCC optimize ("O2,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=998244353;
const int N=310;

int n, m, k, u, v, x, y, t, a, b;
int A[N];
ll dp[N][N][N], ans;
ll ps1[N][N];
ll ps2[N][N];
string S;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>S>>k;
	k=min(k, (int)S.size());
	int ted=0;
	for (char ch:S){
		if (ch=='1') ted++;
		if (ch=='0'){
			A[++n]=ted;
			ted=0;
		}
	}
	A[++n]=ted;
	/*
	debug(n)
	debug(A[1])
	debug(A[2])
	debug(A[3])
	*/	
	dp[n+1][0][0]=1;
	for (int i=n; i; i--){
		for (int t=0; t<=k; t++){
			ps1[0][t]=dp[i+1][0][t];
			for (int j=1; j<=k; j++) ps1[j][t]=(ps1[j-1][t] + dp[i+1][j][t])%mod;
		}
		
		for (int tj=0; tj<=k; tj++){
			ps2[0][tj]=dp[i+1][0][tj];
			for (int j=1; j+tj<=k; j++) ps2[j][tj]=(ps2[j-1][tj] + dp[i+1][j][tj+j])%mod;
		}
		
		for (int j=0; j<=k; j++){
			for (int t=j; t<=k; t++){
//				for (int x=0; x<=min(j, A[i]); x++) dp[i][j][t]+=dp[i+1][j-x][t-x];
				// 0<=x<=min(j, A[i])
				// j>=j-x>=-min(j, A[i])+j
				
				int l=j-min(j, A[i]), r=j;
//				for (int x=l; x<=r; x++) dp[i][j][t]+=dp[i+1][x][t-j+x];

				dp[i][j][t]+=ps2[r][t-j];
				if (l>0) dp[i][j][t]-=ps2[l-1][t-j];

				dp[i][j][t]-=ps1[j][t]-ps1[min(k, t+j)][t];
				dp[i][j][t]%=mod;
			}
		}
	}
	for (int i=0; i<=k; i++) ans+=dp[1][0][i];
	ans%=mod;
	if (ans<0) ans+=mod;
	cout<<ans<<'\n';
	
	
	return 0;
}


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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define MP make_pair
#define FI first
#define SE second
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;

const double EPS = 1e-9;
const double PI = acos(-1);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

ll addMod(ll a, ll b){
	return (a+b) % MOD;
}

ll mulMod(ll a, ll b){
	return (a*b) % MOD;
}

ll fast(ll a, ll b){
	if(b == 0) return 1;
	ll tmp = fast(a,b/2);
	tmp = mulMod(tmp, tmp);
	if(b & 1) tmp = mulMod(tmp, a);
	return tmp;
}

/////////////////////////////////////////////////////////



int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int a,b;
	cin >> a >> b;
	cout << max(max(a+b,a-b), a*b) << endl;
	return 0;
}

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

int main()
{
  int N, A, B, r = 0;
  cin >> N >> A >> B;
  for (int i = 1; i <= N; i++) {
    int sum = 0;
    for (auto s : to_string(i)) {
      sum += (s - '0');
    }
    if ((A <= sum) && (sum <= B)) {
      r += i;
    }
  }

  cout << r << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	int n;
	cin >> n;
	cout << n * 800 - (n/15)*200 << endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<long long> x(n), y(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
        y[i] = x[i];
    }
    sort(y.begin(), y.end());

    long long md1 = y[(n - 1) / 2], md2 = y[(n - 1) / 2 + 1];
    for (int i = 0; i < n; i++) {
        if (x[i] <= md1) {
            cout << md2 << endl;
        }
        else if (x[i] >= md2) {
            cout << md1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 5376