akhauriyash/Code-Regression huggingface dataset:
import copy
import math
import time
import statistics
import math
import itertools
import bisect
from decimal import *

# a = get_int()
def get_int():
    return int(input())
# a = get_string()
def get_string():
    return input()
# a_list = get_int_list()
def get_int_list():
    return [int(x) for x in input().split()]
# a_list = get_string_list():
def get_string_list():
    return input().split()
# a, b = get_int_multi()
def get_int_multi():
    return map(int, input().split())
# a_list = get_string_char_list()
def get_string_char_list():
    return list(str(input()))
# print("{} {}".format(a, b))
# a_list = [0] * a
'''
while (idx < n) and ():

    idx += 1
'''

def main():

    start = time.time()

    x, k, d = get_int_multi()

    wk = k * d

    if x - wk >= 0:
        ans = x - wk
    elif x + wk <= 0:
        ans = abs(x + wk)
    else:
        wk2 = x // d
        if (k - wk2) % 2 == 0:
            ans = abs(x % d)
        else:
            ans = abs(x % d - d)

    print(ans)



if __name__ == '__main__':
    main()




Measured memory_bytes: 11100
#include <iostream>
#include <stdio.h>

using namespace std;

static const int Nmax = 36;

typedef struct Card{
  char suit;
  char value;
} playcard;

void swap(playcard* a, playcard* b)
{
  playcard p = *a;
  *a = *b;
  *b = p;
  return ;
}

void printcards(playcard* array,int length)
{
  for(int i = 0; i < length-1; i++)
  {
    printf("%c%c ",array[i].suit,array[i].value);
  }
  printf("%c%c\n",array[length-1].suit,array[length-1].value);
}

int bubblesort(playcard* A, int N)
{
  int sc = 0;
  for(int i = 0; i < N-1; i++)
  {
    for (int j = N-1 ; j > i; j--)
    {
      if(A[j].value < A[j-1].value)
      {
        swap(&A[j],&A[j-1]);
        sc++;
/*内側のloopサイクルでswapしなかったら全て順番通りに並んでいるので特に問題なく進めます。*/
      }
    }
  }
  return sc;
}

int selectionsort(playcard* A, int N){
  int i;
  int sc = 0;
  for (i = 0; i < N; i++){
    int min_index = i;
    int j;
    for(j = i; j < N; j++){
      if(A[j].value < A[min_index].value){
        min_index = j;
      }
    }
    if (min_index != i){
      swap(&A[i],&A[min_index]);
      sc++;
    }
  }
  return sc;
}

bool eq(playcard A, playcard B){
  if((A.suit == B.suit) & (A.value == B.value))return true;
  return false;
}

bool isStable(playcard* input, playcard* output,int N){
  for(int i = 0; i < N-1;i++){
    for(int j = i+1; j < N ; j++){
      for(int a = 0; a < N-1; a++){
        for(int b = a+1; b < N; b++){
          if((input[i].value == input[j].value) & eq(input[i],output[b]) & eq(input[j],output[a])){
            return false;
          }
        }
      }
    }
  }
  return true;
}

int main(){
  int N;
  playcard A[Nmax],bubble[Nmax],selection[Nmax];
  cin >> N;
  for(int i = 0; i < N ; i++){
    getchar();
    A[i].suit = getchar();
    A[i].value = getchar();
    //printf("%c\n",A[i].suit);
    //printf("%c\n",A[i].value);
    bubble[i] = A[i];
    selection[i] = A[i];
  }
  //printcards(A,N);
  bubblesort(bubble,N);
  selectionsort(selection,N);

  printcards(bubble,N);
  if(isStable(A,bubble,N)){
    printf("Stable\n");
  }
  else{
    printf("Not stable\n");
  }
  printcards(selection,N);
  if(isStable(A,selection,N)){
    printf("Stable\n");
  }
  else{
    printf("Not stable\n");
  }
}



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

class ModCombination {
   private:
    ll max, mod, *fac, *finv, *inv;

   public:
    ModCombination(ll max, ll mod) {
        this->max = max;
        this->mod = mod;
        fac = new ll[max];
        finv = new ll[max];
        inv = new ll[max];
        inv[0] = 0;
        fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
        for (int i = 2; i < max; i++) {
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
    ~ModCombination() {
        delete[] fac;
        delete[] finv;
        delete[] inv;
    }
    ll calc(ll n, ll k) {
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
    }
};

int main() {
    ll N, M, K;
    cin >> N >> M >> K;
    ll mod = 1e9 + 7;
    ll max = N * M;

    ModCombination mc(max, mod);
    ll times = mc.calc(N * M - 2, K - 2);
    ll ans = 0;
    rep(y, N) rep(x, M) {
        ll cost = x + y;
        ll updown = (x == 0 || y == 0) ? 1 : 2;
        ans = (ans + times * cost % mod * ((N - y) * (M - x) * updown)) % mod;
    }
    cout << ans << endl;
    return 0;
}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<ll, ll> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, mx =0;
	cin >>n;
	map<string , int> mp;
	rep(i, n){
		string s; cin >>s;
		mp[s]++;
		mx = max(mx, mp[s]);
	}
	for(auto x: mp) if(x.second==mx) cout << x.first <<"\n";
	
	return 0;
}


Measured memory_bytes: 23808
#include <iostream>
#include<algorithm>
using namespace std;
int main(void){
    // Your code here!
    int a[10];
    for(int i=0;i<3;i++){
        cin>>a[i];
    }
    sort(a,a+3);
    if(a[0]+a[1]==a[2]){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 1; i <= (int)(n); i++)
using ll = long long;
ll gcd(ll a, ll b) {
   if (a%b == 0) {
     return(b);
   } else {
     return(gcd(b, a%b));
   }
}

int main() {
  ll k,ans=0;
  cin >> k;
  rep(a,k){
    rep(b,k){
      rep(c,k){
        ans+= gcd(gcd(a,b),c);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using itn = int;
using ld = long double;
template<class T>
using vec = vector<T>;

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


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

  ld ans=0;
  for(int i=1;i<=n;i++){
    int a=i;
    ld c = 1.0;
    while(a < k){
      c *= 0.50;
      a *= 2;
    }
    ans += c/ld(n);
  }

  cout <<setprecision(15) <<ans <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;



signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;
  int A[N];
  int sum{};
  rep(i,N){
    cin >> A[i];
    sum += A[i];
  }
  if(sum % (4*M) == 0){
    sum /= (4*M);
    sum--;
  }
  else{
    sum /= (4*M);
  }
  int cou{};
  rep(i,N){
    if(A[i] > sum) cou++;
  }
  if(cou >= M){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner scan = new Scanner(System.in);
        
        String before = scan.nextLine();
        
        String after = before.replace( before.substring(0 , 4) , "2018");
        
        System.out.println(after);
    }
    
}

Measured memory_bytes: 35644
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
const int mod=998244353;
int gcd(int a,int b) {return a==0?b:gcd(b%a,a);}
int n,ans=1,a[100010];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++) ans=(LL)ans*gcd(a[i],i-1)%mod;
	printf("%d",ans);
}

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

using namespace std;

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

const ll MOD = 1000000007;

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

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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

//library----------------------------------------------


int main(){
    SCIN(s);
    bool flag = true;
    RepS(i,1,s.size()){
        if(i%2==0&&s[i-1]!='R') continue;
        else if(i%2==1&&s[i-1]!='L') continue;
        else {flag=false; break;}
    }
    printf(flag?"Yes":"No");
    return 0;
}

Measured memory_bytes: 256
// Last Change: 04/06/2019 16:17:02.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS
bool Cal(int N) {
  if (N == 0) {
    return true;
  } else if (N < 0) {
    return false;
  }
  return Cal(N - 4) or Cal(N - 7);
}

int main() {
  int N;
  cin >> N;
  bool ans = Cal(N);

  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#define R(i, n) for(int i = 0; i < n; i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d",  &a, &b, &c)
#define P(a) printf("%d\n", a)
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> IR;

int N, A[100001];

int main(){
	S(N);
	R(i, N){
		int n;
		S(n);
		A[n] = i + 1;
	}
	R(i, N){
		printf("%d ", A[i + 1]);
	}
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int n;
    cin >> n;
    int ans=0, prev=100000000, cur;
    for (int i=0; i<n-1; i++) {
        cin >> cur;
        ans += min(prev, cur);
        prev = cur;
    }
    cout << ans + cur << '\n';
    return 0;
}

Measured memory_bytes: 256
shurui,kona = gets.split(" ").map(&:to_i)
dornuts = Array.new(shurui)
dornuts_cnt = 0
dornuts.map!{ |item|
  item = gets.to_i()
}
dornuts.sort!
dornuts.map{ |item|
  kona = kona - item
  dornuts_cnt+= 1
}
dornuts_cnt += kona/dornuts[0]
p dornuts_cnt

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int x,a,b,c;
  cin>>a>>b>>c>>x;
  int cnt = 0;
  for(int i=0; i<=a; i++){
        int need1 = x - (500*i);
        for(int j=0; j<=b; j++){
            int need2 = need1 - (100*j);
            for(int k=0; k<=c; k++){
                int need3=need2-(50*k);
                if(need3==0) cnt++;
            }
        }
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
B.insert(0, 0)
ans = 0
for i in range(1, N+1):
    if B[i] < A[i-1]:
        ans += B[i]
    else:
        if B[i] - A[i-1] > A[i]:
            ans += A[i-1] + A[i]
            A[i] = 0
        else:
            ans += B[i]
            A[i] -= B[i] - A[i-1]
print(ans)

Measured memory_bytes: 18476
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#define REP(i, n) for(long long i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main() {
	while(1) {
		int t, d, l;
		cin>>t>>d>>l;
		if(t==0&&d==0&&l==0) break;
		int buf = 0;
		int res = 0;
		REP(i, t - 1) {
			int x;
			cin>>x;
			if(x >= l) {
				buf = d - 1;
				res++;
			} else if(buf > 0) {
				++res;
				--buf;
			}
		}
		int x;
		cin>>x;
		cout<<res<<endl;
	}
}

Measured memory_bytes: 3080
n = input()
t = 1
for i in range(len(n)):
    if i%2==0:
        if n[i] == "L":
            t=0
            break
    else:
        if n[i]== "R":
            t = 0
            break
if t ==1:
    print("Yes")
else:print("No") 


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#ifdef RUBICK
#include "dbg.h"
#else
#define dbg(exp) /* nop; */
#endif

using namespace std;
using namespace __gnu_pbds;

template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;

int main() {
    string S;
    cin >> S;

    for (int i = 0; i < S.size(); i += 2)
        cout << S[i];
    cout << '\n';

    return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a,b,c;
int main()
{
	cin>>a>>b>>c;
	for(int i=0;i<10;i++)
	{
		c=a*c-b;
		cout<<c<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*


fun solve() {
    val S = rd.readString()
    val N = S.length

    val A = LongArray(N+1){0L}

    for (i in 0 until N) {
        if (S[i] == '<') {
            A[i+1] = max(A[i+1], A[i]+1)
        }
    }
    for (i in N-1 downTo 0) {
        if (S[i] == '>') {
            A[i] = max(A[i], A[i+1]+1)
        }
    }

    val ans = A.sum()
    println(ans)
}


//val rd = debug.Reader("agc", "040", "a", "sample-2")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!! }
    catch (e: Exception) { throw e }
    finally { rd.close() }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int)
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
    val readListIntCol: (Int) -> List<Int> = { N -> (0 until N).map { readInt() } }
    val readListIntCols: (Int) -> List<List<Int>> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toInt() } } }
    val readListLongCol: (Int) -> List<Long> = { N -> (0 until N).map { readLong() } }
    val readListLongCols: (Int) -> List<List<Long>> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toLong() } } }
    val close: () -> Unit = { br.close() }
    protected fun finalize() { close() }
}


Measured memory_bytes: 46116
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    N = int(readline())
    m = map(int,read().split())
    XY = list(zip(m,m))

    ans = 0
    z = [x-y for (x, y) in XY]
    # print(z)
    z.sort()
    ans = z[-1] - z[0]
    z = [x+y for (x, y) in XY]
    # print(z)
    z.sort()
    ans = max(ans, z[-1] - z[0])

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 130156
#include<stdio.h>
    int main()
    {
        double x1,x2,x3,y1,y2,y3,q,m1,c1,c2,X,Y,m2,i;
        scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
        scanf("%lf",&q);
        for(i=0;i<q;i++)
        {
            scanf("%lf %lf",&x3,&y3);
            if(x1==x2)
            {
                X=x2;
                Y=y3;
            }
            else if(y1==y2)
            {
                Y=y1;
                X=x3;
            }
            else
            {
                m1=(y1-y2)/(x1-x2);
                c1=y1-m1*x1;
                m2=-1/m1;
                c2=y3-m2*x3;
                X=(c2-c1)/(m1-m2);
                Y=m2*X+c2;}
            printf("%.10lf %.10lf\n",X,Y);
        }
    	return 0;
    }

  // ALHAMDULLIAH





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

int main() {
	
	int n, k; cin >> n >> k;
	int ans = 1;
	while (true) {
		int tmp = k + (k - 1) * (ans - 1);
		if (n <= tmp) {
			break;
		}
		ans++;
	}
	cout << ans << endl;
	return 0;
}

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


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    int n,a,b;
    cin>>n>>a>>b;
    int ans = 0;
    for(int i=0;i<n;i++){
        int c;
        cin>>c;
        if(c>=a && c<b);
        else ans++;
    }
    cout << ans << endl;
}

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


long long N,M;
vector<int> G[100010];
int color[100010] = {0};
long long sum[5] = {0};

bool DFS(int v,int c)
{
    color[v] = c;
    if(c == 1)sum[0]++;
    else sum[1]++;
    for(int i = 0; i < G[v].size(); i++)
    {
        if(color[G[v][i]] == c)return false;
        if(color[G[v][i]] == 0 && !DFS(G[v][i],-c))return false;
    }
    return true;
}

int main()
{
    scanf("%lld%lld",&N,&M);
    for(int i = 0; i < M; i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        G[a].push_back(b);
        G[b].push_back(a);
    }

    if(DFS(1,1))printf("%lld\n",sum[0] * sum[1] - M);
    else printf("%lld\n",(N - 1) * N / 2 - M);
    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,k,x,y;
int32_t main(){
CODE_START;
cin>>n;
cin>>k;
cin>>x;
cin>>y;
if(k>=n){
    rc(x*n);
}else{
rc(x*k+(n-k)*y);
}
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
using namespace std;
using LL = long long;

int n;
int arr[114][514];

int main(void)
{
	cin >> n;
	for (int i = 0; i < n; ++i)for (int j = 0; j < n; ++j)
	{
		cin >> arr[i][j];
	}
	LL ans = 0;
	for (int i = 0; i < n; ++i)for (int j = 0; j < n; ++j)
	{
		ans += min(arr[i][j], arr[j][i]);
	}
	cout << ans / 2 << endl;
	return 0;
}

Measured memory_bytes: 3276
#include <iostream>
using namespace std;
int main(){
    int hp , n , sum = 0 , x;
    cin >> hp >> n;
    for (int i = 0 ; i < n ; i++) {
        cin >> x;
        sum += x;
    }
    if (sum >= hp) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        OutputStream pr = System.out;
        PrintWriter out = new PrintWriter(pr);
        int n = sc.nextInt();
        double[] array = new double[n];
        for(int i=0;i<n;i++){
            array[i]=sc.nextDouble();
        }
        double d=0.0;
        if(n==1){
            d = array[0];
        }else if(n==2){
            d = (array[0]+array[1])/2;
        }else{
            Arrays.sort(array);
            d = (array[0]+array[1])/2;
            for(int i=2;i<n;i++){
                d=(d+array[i])/2;
            }
        }
        out.print(d);
        out.close();
    }
    public static long gcd(long a,long b){
        if(a==0){
            return b;
        }else{
            return gcd(b%a,a);
        }
    }
}

Measured memory_bytes: 24660
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

# define INF 0x3f3f3f3f

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

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

  string S;
  cin >> S;

  if (S == "AKIHABARA" ||
      S == "KIHABARA" ||
      S == "AKIHBARA" ||
      S == "AKIHABRA" ||
      S == "AKIHABAR" ||
      S == "KIHBARA" ||
      S == "KIHABRA" ||
      S == "KIHABAR" ||
      S == "AKIHBRA" ||
      S == "AKIHBAR" ||
      S == "AKIHABR" ||
      S == "KIHBRA" ||
      S == "KIHBAR" ||
      S == "KIHABR" ||
      S == "AKIHBR" ||
      S == "KIHBR") {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define COUT(a) cout << (a);
#define ENDL cout << "\n";

int main() {
    int n,tmp;
    scanf("%d\n",&n);
    int a[n];
    REP(i,n) scanf("%d",&a[i]);
    sort(a,a+n);
    int min = 1000000;
    int index=0;
    while(index+1!=n){
        for(int i=index+1;i<n;i++) {
            tmp = a[i]%a[index];
            a[i] = tmp;
        }
        sort(a,a+n);
        REP(i,n) if(a[i]!=0) {
            index=i;
            break;
        }
    }
    COUT(a[n-1])
}





Measured memory_bytes: 640
n, m = map(int, input().split())
a_list = []
for i in range(n):
	a_list.append(list(map(int, input().split())))
b_list = []
for i in range(m):
	b_list.append(int(input()))
for a_rows in a_list:
	x_list = []
	index = 0
	for a in a_rows:
		x_list.append(a*b_list[index])
		index += 1
	print(sum(x_list))


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

int main(){
  int N,x;
  cin>>N>>x;
  vector<int> a(N);
  for(int &i:a)
    cin>>i;
  sort(a.begin(),a.end());
  int i=0;
  for(;i<N;i++){
    x-=a[i];
    if(x==0)
      i++;
    if(x<=0)
      break;
    if(i==N-1)
      i++;
  }
  if(i==N+1)
    cout<<N-1;
  else
    cout<<i<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<string>
#include<numeric>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using vi = vector<int>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using vpii = vector<pii>;

int main(){
  int N;
  cin >> N;
  int tmp;
  int total = 0;
  int ans = 0;
  rep(i, N){
    cin >> tmp;
    ans += total*tmp;
    total += tmp;
  }

  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
#define sqr(x) ((x)*(x))
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

const LL MOD = 1e9+7;

LL qpow(LL a, LL b) {
    LL ret = 1;
    while(b) {
        if(b & 1) (ret *= a) %= MOD;
        (a *= a) %= MOD;
        b >>= 1;
    }
    return ret;
}

void run_case() {
    LL n;
    cin >> n;
    if(n == 1) {
        cout << 0;
        return;
    }
    cout << ((qpow(10, n) - qpow(9,n) - qpow(9, n) + qpow(8, n))%MOD+MOD)%MOD;
    
}


int main() {
    //freopen("input", "r", stdin);
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(6);
    //int t; cin >> t;
    //while(t--)
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int n, m;
map<int,int>mpm,mpt , mp; 
int ans;
int main(){
	cin>>n>>m;
	for(int i = 0; i < n ;i++){
		int x;cin>>x;
		mpm[x%m]++;
		mpt[x]++;
	}
	for(int i= 0; i < m ; i++){
		int ts = (m-i)%m;
		if(ts == i){
			ans+=mpm[i]/2;
			mp[i] =mpm[i]%2;
		}else if(ts > i){
			int tt = min(mpm[i] , mpm[ts]);
			ans+=tt;
			mp[i] = mpm[i] - tt;
			mp[ts] = mpm[ts]-tt;
		}else break;
	}
	for(int i = 1 ;i <= 100000 ; i++){
		int z  =min(mpt[i] ,mp[i%m])/2;
		ans+=z;
		mp[i%m]-=(2*z);
	}
	cout<<ans;
	return 0;
}



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

int main()
{ 
  string s;
  int ans = 0, tmp = 0;

  cin >> s;
  for (int i = 0; i < s.size(); i++)
  {
    if (string("ACGT").find(s[i]) != std::string::npos)
      tmp++;
    else
    {
      ans = max(ans, tmp);
      tmp = 0;
    }
  }
  ans = max(tmp, ans);
  cout << ans << endl;
}

Measured memory_bytes: 256
def gcd(a,b):
    if a==b:
        return b
    elif a%b == 0:
        return b
    else:
        return gcd(b,a%b)

n,m = map(int,input().split())
s = input()
t = input()
if n<m:
    tmp = m
    m = n
    n = tmp
    tmp = s
    s = t
    t = tmp
lcm = (n*m)//gcd(n,m)
ok = True
if s[0] != t[0]:
    ok = False

for i in range(1,gcd(n,m)-1):
    if s[n//gcd(n,m)*i] != t[m//gcd(n,m)*i]:
        ok = False
        break
print(lcm if ok else -1)


Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;

int f[maxn][2];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
#endif
  string s;
  cin>>s;
  int n = s.size();
  f[0][1]=1;
  for(int i=0;i<n;i++)
    for(int j=0;j<2;j++){
      int limit = 1;
      if(j&&s[i]=='0')limit=0;
      for(int k=0;k<=limit;k++){
        int st = (j==1&&k==limit);
        f[i+1][st]=(f[i+1][st]+f[i][j]*(k+1)%mod)%mod;
      }
    }
  cout<<(f[n][0]+f[n][1])%mod<<endl;
  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

llong  Ryuca(int n)// nは回数
{
    vector<llong> L(87);
    L[0]=2;
    L[1]=1;
    for(int i=2; i<=n; i++)
    {
        L[i]=L[i-1]+L[i-2];
    }
    return L[n];
}

int main()
{
int n;
cin>>n;
cout<<Ryuca(n)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main(){
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  long long int count = 0;
  int rmax = N/R;
  for(int r = 0; r <= rmax; r++){
	int n = N - r * R;
    int gmax = n / G;
    for(int g = 0; g <= gmax; g++){
      if((n - g*G) % B == 0){
        count++;
      }
    }
  }
  
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n;
	scanf("%d",&n);
	int x  =  n;
	int dig;
	int sum =0;
	while(n>0){
		dig = n%10;
		sum +=dig;
		n /=10;
	}
	if(x%sum==0)printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 128
fun main(args: Array<String>)
{
    val n = readInt()
    val hs = readNInts().toIntArray()

    var ans = true
    for (i in n-1 downTo 1)
    {
        if (hs[i-1] > hs[i] + 1)
        {
            ans = false
            break
        }
        else if (hs[i-1] == hs[i] + 1)
        {
            hs[i-1] -= 1
        }
    }

    println(if (ans) "Yes" else "No")
}

// Read an integer
// Usage: val a = readInt()
fun readInt() = readLine()!!.toInt()

// Read N integers separated by " "
// Usage: val (a, b, c) = readNInts()
fun readNInts() = readLine()!!.split(" ").map(String::toInt)

// Read a string
// Usage: val a = readString()
fun readString() = readLine()!!


Measured memory_bytes: 61448
#include<iostream>

using namespace std;

int main() {
	int N;
	int A[200000];
	cin >> N;
	int max = 0;
	int max2 = 0;
	int count = 0;
	int count2 = 0;
	for (int i = 0;i < N;i++) {
		cin >> A[i];
		if (max < A[i]) {
			max2 = max;
			max = A[i];
			count = i;
		}
		else if (max2 < A[i]) {
			max2 = A[i];
		}
	}
	for (int i = 0;i < N;i++) {
		if (count != i) {
			cout << max << endl;
		}
		else {
			cout << max2 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;

int main(){
    int n;
    scanf("%d", &n);
    priority_queue<double, vector<double>, greater<double>> que; 
    rep(i, n){
        double v;
        scanf("%lf", &v);
        que.push(v);
    }
    while(true){
        double a = que.top(); que.pop();
        if(que.empty()){
            printf("%.10lf\n", a);
            return 0;
        }
        double b = que.top(); que.pop();
        que.push((a+b)/2);
    }
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve(a int) int {
  change := a % 1000
  if change != 0 {
    change = 1000 - change
  }

  return change
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	line1 := scanner.Text()

	a, _ := strconv.Atoi(line1)
  change := solve(a)

	fmt.Printf("%d\n", change)
}


Measured memory_bytes: 1772
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include<unordered_map>
#include <set>
#include<unordered_set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <math.h>
#define lli long long int
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

void solve()
{
    lli n;
    cin>>n;
    string s;
    cin>>s;
    for(int i = 0; i < s.size(); i ++) {
        lli t = n;
        while(t --) {
            if(s[i] == 'Z')
                s[i] = 'A';
            else
                s[i] ++;
        }
    }
    cout<<s;
    cout<<'\n';
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}
/*
1
5
1 2
2 3
3 4
4 5
1
3
*/


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int a, b, c;cin >> a >> b >> c;
    cout << min(b/a, c) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    char s[101];
    int K,length,i;
    
    
    scanf("%d",&K);
    scanf("%s",s);
    
    length=strlen(s);
    
    if(length<=K){
        printf("%s\n",s);
    }else{
        
        for(i=0;i<K;i++){
            printf("%c",s[i]);
        }
        printf("...\n");
    }
    
    return 0;
}

Measured memory_bytes: 2088
// ConsoleApplication1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
#define show(ans) cout << ans << endl
const long MOD = 1000000007;

int main() {
	long N, M;
	long k, tmp;

	cin >> N >> M;
	vector<long> cnt(M + 1);
	erep(i, N) {
		cin >> k;
		erep(j, k) {
			cin >> tmp;
			cnt[tmp]++;
		}
	}
	long ans = 0;
	erep(i, M) {
		if (cnt[i] == N) {
			ans++;
		}
	}
	show(ans);
	return 0;

}
// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
#define pii pair<LL,LL>

using namespace std;

int main(){
    int N;
    cin>>N;
    LL a[N];
    REP(i,N)cin>>a[i];
    LL cnt[N];
    fill_n(cnt,N,0);

    priority_queue<pii> que;
    REP(i,N)que.push({a[i],i});

    LL Min = N-1,num=0,clum=0;

    while(!que.empty()){
        pii p = que.top();que.pop();
        cnt[Min]+=(num-p.first)*clum;
        Min = min(Min,p.second);
        num = p.first;
        clum++;
    }
    cnt[Min]+=num*clum;
    REP(i,N)cout<<cnt[i]<<endl;


        return 0;
};

Measured memory_bytes: 4336
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    mod=10**9+7
    stone=[0]*(2*10**5+1)
    stone_last_pos=[-1]*(2*10**5+1)
    dp=[0]*(n+1)
    dp[0]=1
    for i in range(1,n+1):
        c=int(input())
        place=stone_last_pos[c]
        if place==i-1 or place==-1:
            dp[i]=dp[i-1]
        else:
            dp[i]=(dp[i-1]+dp[place])%mod
        stone_last_pos[c]=i
    print(dp[n])


if __name__=='__main__':
    main()

Measured memory_bytes: 45420
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  sort(S.begin(),S.end());
  int i;
  for(i=1;i<S.size();i++)if(S.at(i)==S.at(i-1))break;
  if(i==S.size())cout<<"yes"<<endl;
  else cout<<"no"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
int B[MAXN];
int tree[MAXN*4];
vector<int> val;

void update(int tmp,int v)
{
    tree[tmp]+=v;
    tmp>>=1;

    while(tmp){
        tree[tmp] = tree[tmp<<1]+tree[((tmp<<1)|1)];
        tmp>>=1;
    }

    return;
}

int getans(int L,int R)
{
    int res = 0;

    while(L<=R){
        if(L&1){res+=tree[L]; L++;}
        if(!(R&1)){res+=tree[R]; R--;}
        L>>=1; R>>=1;
    }

    return res;
}

bool ok(int x,int n)
{
    for(int i=1;i<=n;i++){
        if(A[i]>=x)B[i] = 1;
        else B[i] = -1;
    }

    for(int i=1;i<=n;i++)
        B[i]+=B[i-1];

    vector<int> tmp;

    for(int i=0;i<=n;i++)
        tmp.push_back(B[i]);

    sort(tmp.begin(),tmp.end());

    tmp.erase(unique(tmp.begin(),tmp.end()),tmp.end());

    int base = 1;
    int tsz = tmp.size();
    int idx;

    for(;base<tsz;base<<=1);

    for(int i=1;i<(base<<1);i++)tree[i] = 0;

    ll res = 0;

    for(int i=0;i<=n;i++){
        idx = lower_bound(tmp.begin(),tmp.end(),B[i])-tmp.begin();
        res+=(ll)getans(base,base+idx);
        update(base+idx,1);
    }
    return (2*res>=(1LL*n*(n+1)/2));
}

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;

    for(int i=1;i<=n;i++)
    {
        cin>>A[i];
        val.push_back(A[i]);
    }

    sort(val.begin(),val.end());
    val.erase(unique(val.begin(),val.end()),val.end());

    for(int i=1;i<=n;i++){
        idx = lower_bound(val.begin(),val.end(),A[i])-val.begin();
        A[i] = idx;
    }

    int sz = val.size();

    int L = 0;
    int R = sz-1;
    int mid,ans = 0;

    while(L<=R){
        mid = (L+R)>>1;
        if(ok(mid,n))ans = mid,L = mid+1;
        else R = mid-1;
    }

    cout<<val[ans]<<"\n";

    return 0;
}


Measured memory_bytes: 4916
package main

import (
  "fmt"
)

func maxInt(a ...int) int {m := a[0]; for _, x := range a {if x > m {m = x}}; return m}
func minInt(a ...int) int {m := a[0]; for _, x := range a {if x < m {m = x}}; return m}

func main() {
  var a, b, k int
  fmt.Scan(&a, &b, &k)
  if k * 2 >= b - a + 1 {
    for i := a ; i < b + 1; i ++ {
      fmt.Println(i)
    }
  } else {
    for i := a; i < a + k; i++ {
      fmt.Println(i)
    }
    for i := b - k + 1; i < b + 1; i++ {
      fmt.Println(i)
    }
  }
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    
    int[][] s = new int[N][2];
    for (int i = 0; i < N; i++) {
      s[i][0] = sc.nextInt();
      s[i][1] = sc.nextInt();
    }
    
    int[][] cp = new int[M][2];
    for (int i = 0; i < M; i++) {
      cp[i][0] = sc.nextInt();
      cp[i][1] = sc.nextInt();
    }
    
    for (int i = 0; i < N; i++) {
      int minValue = Integer.MAX_VALUE;
      int minIdx = 0;
      for (int j = 0; j < M; j++) {
        int value = Math.abs(s[i][0]-cp[j][0]) + Math.abs(s[i][1]-cp[j][1]);
        if (value < minValue) {
          minValue = value;
          minIdx = j;
        }
      }
      System.out.println(minIdx+1);
    }
  }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define INF 1000000000
using namespace std;


//=============modinv============================
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// long long main() {
//     // mod. 13 での逆元を求めてみる
//     for (long long i = 1; i < 13; ++i) {
//         cout << i << " 's inv: " << modinv(i, 13) << endl;
//     }
// }
//=================================================


//=============modpow============================
long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//=================================================

int main()
{
  long long mod = 1000000007;
  long long N;
  cin >> N;
  long long a, b;
  cin >> a >> b;
  long long ans = modpow(2, N, mod);
  // cout << ans << endl;
  long long below = 1;
  long long up = 1;
  for (long long i = 2; i < a + 1; ++i)
  {
    below = (below * modinv(i, mod)) % mod;
  }
  for (long long i = N - a + 1; i < N + 1; ++i)
  {
    up = (up * i) % mod;
  }
  ans = ans - ((below * up) % mod);
  if (ans < 0)
  {
    ans += mod;
  }
  below = 1;
  up = 1;
  for (long long i = 2; i < b + 1; ++i)
  {
    below = (below * modinv(i, mod)) % mod;
  }
  for (long long i = N - b + 1; i < N + 1; ++i)
  {
    up = (up * i) % mod;
  }
  ans = ans - ((below * up + 1) % mod);
  if (ans < 0)
  {
    ans += mod;
  }
  ans = ans % mod;
  cout << ans << endl;
}


Measured memory_bytes: 764
#!/usr/bin/env python3
n = int(input())
class Node:
  def __init__(self):
    self.p = -1 # parent
    self.l = None # left most child
    self.r = None # right sibling

T = [Node() for _ in range(n)]
D = [0]*n

def rec(u,p):
  D[u] = p
  if T[u].r != None: rec(T[u].r,p)
  if T[u].l != None: rec(T[u].l,p+1)

for i in range(n):
    a = input().split()
    v = int(a[0])
    for j,c in enumerate(map(int,a[2:])):
      if j == 0: T[v].l = c
      else: T[pre].r = c
      pre = c
      T[c].p = v

for i in range(n):
  if T[i].p == -1 : r = i
import sys  
sys.setrecursionlimit(150000)
rec(r,0)
for i in range(n):
  if T[i].p == -1:
    kind = "root"
  elif T[i].l != None: kind = "internal node"
  else: kind = "leaf"
  c = []
  n = T[i].l
  while n != None:
    c.append(n)
    n = T[n].r
  print("node {}: parent = {}, depth = {}, {}, {}"
        .format(i,T[i].p,D[i],kind,c))


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;

#define maxn 300005
#define INF 2000000000
#define alpha 26

i64 f( i64 i , i64 j , i64 l )
{
    i64 ans = 0 ;

    ans += (i/2)*4 ;
    i%=2 ;

    ans += (j/2)*4 ;
    j%=2 ;

    ans += (l/2)*4 ;
    l%= 2 ;

    if(i==1 && j==1 &&l==1) ans += 6 ;

    return ans ;
}

int main()
{
    i64 i , o  , t , j , l , s , z ;

    scanf("%lld %lld %lld %lld %lld %lld %lld",&i,&o,&t,&j,&l,&s,&z) ;

    i64 ans1 = f(i,j,l) , ans2 = 0 ;

    if( i>0 && j>0 && l>0 ) ans2 = f(i-1,j-1,l-1) + 6 ;

    i64 ans = max(ans1,ans2) ;

    ans += o*2 ;

    printf("%lld\n",ans/2) ;

    return 0 ;
}


Measured memory_bytes: 256
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
using namespace std; 
 
const int N = 2e5 + 1000, OO = 1e14 + 100, M = 1e9 + 7, P = 6151, SQ = 120, lg = 31;
typedef pair <int, int> pii;
bool b[N];
int sum[N];

int32_t main() {
    use_fast;
    int n, m, ans = 0, pen = 0;
    cin >> n >> m;
    while(m--) {
    	int x;
    	string s;
    	cin >> x >> s;
    	if(b[x] == true)
    		continue;
    	if(s == "AC") {
    		ans++;
    		b[x] = true;
    		pen += sum[x];
		}
		else 
			sum[x]++;
	}
	cout << ans << " " << pen << endl;
	return 0;
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ... 
*/	

Measured memory_bytes: 1152
#include<iostream>
#include<cstdio>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FOF(i,a,b) for(int i=a;i< b;i++)
using namespace std;
const int N=2002000;
int n,m,K,l,r,T,x,L;
int q[N],p[N],c[N],d[N],a[N],b[N];
char s[N],t[N];
void psp(int x,int y){p[++l]=x,d[l]=y;}
void psh(){
	//FOR(i,1,r) cout<<q[i]<<','<<c[i]<<' ';cout<<'\n';
	for(l=0,x=K;x>0;){
		int w=q[r],u;
		if(w==0){
			int v=min(c[r],x);
			psp(w,v);x-=v;
			c[r]>v?c[r]-=v:r--;
		}
		else{
			psp(0,1);psp(w^3,1);
			if(c[r]>1) psp(0,c[r]-1);
			u=q[--r];c[r]>1?c[r]--:r--;
			!u?psp(w,1),x=-1:x--;
		}
		//cout<<"x="<<x<<':';FOR(i,1,r) cout<<q[i]<<','<<c[i]<<' ';cout<<'\n';
	}
	if(~x) psp(3,1);
	while(l) q[r]!=p[l]?q[++r]=p[l],c[r]=d[l--]:c[r]+=d[l--];
	//FOR(i,1,r) cout<<q[i]<<','<<c[i]<<' ';cout<<'\n';
}
void opt(int*A){
	int ok=0;
	FOR(i,1,T)if(ok||A[i]) ok=1,cout<<A[i];cout<<'\n';
}
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d%d%d",&n,&m,&K);
	scanf("%s%s",s+1,t+1);L=max(n,m)+K+1;
	FOF(i,0,n) a[L-i]=s[n-i]^48;
	FOF(i,0,m) b[L-i]=t[m-i]^48;
	FOR(i,1,L){
		int w=a[i]|b[i]<<1;
		if(w<3) !r||q[r]!=w?q[++r]=w,c[r]=1:++c[r];
		else psh();
	}
	FOR(i,1,r)while(c[i]--) a[++T]=q[i]&1,b[T]=q[i]>>1;
	opt(a);opt(b);
}

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

int W, H, x, y, r;

int main() {
    cin >> W >> H >> x >> y >> r;
    
    if (x - r < 0 || W < x + r || y - r < 0 || H < y + r) {  // ||でまたは，一つでも条件に合わないときに外される
            cout << "No" << endl;

    } else {
        cout << "Yes" << endl;
        
    }
    
    return 0;
}



Measured memory_bytes: 3108