akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include <iostream>
#include <string.h>
#include <algorithm>
 size_t strlen(const char *s);
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int N=100010;
const int P=1000000007;
int compare_int(const void *a, const void *b)
{
    return *(long long int*)a - *(long long int*)b;//a-b昇順
}
//絶対値
int ze(int a, int b){
	if(a>b){
		return a-b;
	}else{
		return b-a;
	}
}
// a^n mod 
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;
}

// a^{-1} mod 
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

//mod掛け算
long long mt(long long a, long long b, long long mod){
	return (a*b)%mod;
}

//メモ
//	cout<<(n-2)*180<<endl;
//	string s="hoge";
//	cout<<ans<<endl;
//	int  n  ,a  ,b  ,c  ,d  ,e  ,f  ;
//	cin  >>n  >>a  >>b  >>c  >>d  >>e  >>f  ;

/*
	memset(b, '\0', sizeof(b));
初期化*/
/*
	len = strlen(s);
文字列長さ*/
/*
	string s;
	s.size()
*/
/*ソート
	qsort(b, 10, sizeof(int), compare_int);
*/
/*
	char s[N];
	strlen(s)
/*
	if(  <  )puts("YES");
	else puts("NO");
*/

int main(){
	int n, a,b;
	cin  >>n  >>a>>b  ;
	printf("%d\n",min(a*n,b));

}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func sort(r []rune) {
	for i := 0; i < len(r); i++ {
		for j := len(r) - 1; j >= i+1; j-- {
			if r[j-1] > r[j] {
				r[j-1], r[j] = r[j], r[j-1]
			}
		}
	}
}

func rsort(r []rune) {
	for i := 0; i < len(r); i++ {
		for j := len(r) - 1; j >= i+1; j-- {
			if r[j-1] < r[j] {
				r[j-1], r[j] = r[j], r[j-1]
			}
		}
	}
}

func main() {
	var s, t string
	fmt.Scan(&s, &t)

	sr := []rune(s)
	tr := []rune(t)

	sort(sr)
	rsort(tr)

	if string(sr) < string(tr) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

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

using namespace std;

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

int main(){
	int h,w; cin>>h>>w;
	string B[50];
	rep(i,h) cin>>B[i];

	int d[50][50];
	rep(i,h) rep(j,w) d[i][j]=(i==0&&j==0?0:-1);

	int Q[50*50],l=0,r=0;
	Q[r++]=0;
	while(l<r){
		int p=Q[l++];
		int y=p/w,x=p%w;
		rep(k,4){
			int yy=y+dy[k],xx=x+dx[k];
			if(0<=yy && yy<h && 0<=xx && xx<w && !~d[yy][xx] && B[yy][xx]=='.'){
				d[yy][xx]=d[y][x]+1;
				Q[r++]=yy*w+xx;
			}
		}
	}

	if(!~d[h-1][w-1]){ cout<<-1<<endl; return 0; }

	int ans=h*w-d[h-1][w-1]-1;
	rep(i,h) rep(j,w) if(B[i][j]=='#') ans--;
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
S = gets.chomp
leng = S.length
a = S.split("")
b = Array.new

for i in 0..leng-1
    
    if a[i] == '0' 
        b.push(0)
    elsif a[i] == '1'
        b.push(1)
    elsif a[i] == 'B' && b.size > 0
        b.pop
    end

end

puts b.join('')

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

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

    queue<pair<string, int> > qp;
    for (int i = 0; i < n; i++) {
        string s;
        int tt;
        cin >> s >> tt;
        qp.push(make_pair(s, tt));
    }

    int T = 0;
    for (; qp.size();) {
        pair<string, int> p = qp.front();
        qp.pop();
        if (p.second <= t) T += p.second, cout << p.first << " " << T << endl;
        else qp.push(make_pair(p.first, p.second - t)), T += t;
    }

    return 0;
}



Measured memory_bytes: 6280
#include<stdio.h>

int main(void) {
  int k, a, b;
  scanf("%d", &k);
  scanf("%d %d", &a, &b);
  if(a%k == 0||k-a%k <= b-a) {
    printf("OK\n");
  }
  else {
    printf("NG\n");
  }
  return 0;
}


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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

int main ()
{
    st s ;

    cin >> s ;

    if (s == "Sunny")
        cout << "Cloudy" ;
    if (s == "Cloudy")
        cout << "Rainy" ;
    if (s == "Rainy")
        cout << "Sunny" ;


    return 0 ;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N, M int
	fmt.Scan(&N, &M)

	Hs := make([]int, N)
	for i, _ := range Hs {
		fmt.Scan(&Hs[i])
	}

	As := make([]int, M)
	Bs := make([]int, M)
	result := make([]bool, N)
	for i, _ := range As {
		fmt.Scan(&As[i], &Bs[i])
		if Hs[As[i]-1] > Hs[Bs[i]-1] {
			result[Bs[i]-1] = true
		} else if Hs[As[i]-1] < Hs[Bs[i]-1] {
			result[As[i]-1] = true
		} else {
			result[As[i]-1] = true
			result[Bs[i]-1] = true
		}
	}

	counter := 0
	for _, v := range result {
		if v != true {
			counter++
		}
	}
	fmt.Println(counter)
}


Measured memory_bytes: 7312
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string S;
	cin >> S;

	Int flag = 1;
	Int len = S.size();
	if (S[0]!='A') {
		flag = 0;
	}

	if (S[1] >= 'A' && S[1] <= 'Z') {
		flag = 0;
	}

	Int flagc = 0;//Cがあるかどうか
	for (Int i = 2; i < len-1; i++) {
		if (flagc==0) {
			if (S[i]=='C') {
				flagc = 1;
				continue;
			}
			if (S[i] >= 'A' && S[i] <= 'Z') {
				flag = 0;
			}
		}
		else {
			if (S[i]=='C') {
				flag = 0;
			}
			if (S[i] >= 'A' && S[i] <= 'Z') {
				flag = 0;
			}
		}
	}
	if (flagc==0) {
		flag = 0;
	}

	if (S[len-1] >= 'A' && S[len-1] <= 'Z') {
		flag = 0;
	}

	if (flag) cout << "AC" << "\n";
	else cout << "WA" << "\n";
}


Measured memory_bytes: 256
<?php
list($n,$k)=explode(" ",trim(fgets(STDIN)));
$h = explode(" ",trim(fgets(STDIN)));
$i=0;
$ans=0;
while($i<$n){
  if($h[$i] >= $k){
    ++$ans;
  }
  ++$i;
}
echo $ans;

Measured memory_bytes: 12920
import java.util.*

class Scanner(`in`: java.io.InputStream) {
    private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))
    private var tokenizer: StringTokenizer? = null

    fun next(): String {
        if (tokenizer?.hasMoreTokens() != true) {
            tokenizer = StringTokenizer(reader.readLine())
        }
        return tokenizer!!.nextToken()
    }

    fun nextLine(): String {
        return if (tokenizer?.hasMoreTokens() != true) {
            reader.readLine()
        } else tokenizer!!.nextToken("\n")
    }
}

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val X = sc.next().toLong()
        var ans = (X / 11) * 2
        val r = X % 11
        if (r in 1..6) {
            ans++
        } else if (r > 6) {
            ans += 2
        }
        pw.println(ans)
    }
}


Measured memory_bytes: 29476
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int n;cin >> n;
	int a[n];
	rep(i,n)cin >> a[i];
	int ret = 0;
	
	while(1){
		bool changed = false;
		rep(i,n){
			if(a[i])changed = true;
		}
		if(!changed)break;
		for(int i = 0,j;i < n; i = j){
			for(;i < n && a[i] == 0;i++);
			if(i == n)break;
			//trace(i,j);
			for(j = i;j < n && a[j] != 0;j++){
				a[j]--;
			}
			ret++;
		}
		
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3604
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
//const n = +input[0];
//const a = [];
//for(let i=0;i<n;i++){
//	a.push(input[i+1].split(" ").map((x:string):number=>+x));
//}

//const [n, m] = input[0].split(" ").map((x: string): number => +x);
//const a = input[1].split(" ").map((x: string): number => +x);

function compareFunc(a, b){
    return a-b;
}

const n = +input[0];
const a = input[1].split(' ').map((x: string): number => +x);

let bunbo: number = 0;

for(let i = 0; i < n; i++){
    bunbo+=(1/a[i]);
}
console.log(1/bunbo);

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

int main() {

	string m1, d1, m2, d2; cin >> m1 >> d1 >> m2 >> d2;
	int ans;
	if (d2.size() == 1 && d2 == "1") {
		ans = 1;
	}
	else ans = 0;
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    S = input()
    T = input()

    l = len(S)

    def judge():
        for i in range(l):
            U = S[l - i:] + S[:l - i]
            if U == T:
                return True
        return False

    if judge():
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()


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

int main(){
    string S,T;
    cin >> S >> T;
    int A,B;
    cin >> A >> B;
    string U;
    cin >> U;
    if(U == S){
        cout << A-1 << " " << B << endl;
    }else{
        cout << A << " " << B-1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
blist=[list(map(int,input().split())) for i in range(3)]
n = int(input())
alist=[int(input()) for i in range(n)]

count = [[0,0,0],[0,0,0],[0,0,0]]

for i in range(0,n):
   for j in range(0,3):
      for k in range(0,3):
         if alist[i] == blist[j][k]:
            count[j][k] += 1

ans = 0
temp = 0

for i in range(0,3):
   for k in range(0,3):
      if count[i][k] == 1:
         temp += 1
      if temp == 3:
         ans += 1
   temp = 0

for i in range(0,3):
   for k in range(0,3):
      if count[k][i] >= 1:
         temp += 1
      if temp == 3:
         ans += 1
   temp = 0

if count[0][0] == 1 and count[1][1] == 1 and count[2][2] == 1:
   ans += 1
if count[0][2] == 1 and count[1][1] == 1 and count[2][0] == 1:
   ans += 1

if ans == 0:
   print('No')
else:
   print('Yes')

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

#define REP(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ALL(c) c.begin(), c.end()
#define SZ(c) (int) c.size()
#define DBG1(x) cout<<#x<<" = "<<x<<"\n"
#if USE_CP_REDIR
#define CP \
    freopen("input.txt","r", stdin); \
    freopen("output.txt","w", stdout);
#endif

using ll = long long;
const ll MOD = 1'000'000'007;
const int MN = 1'000'000;

int main()
{
ios::sync_with_stdio(false);
#ifdef CP
    CP;
#endif
    int N;
    cin >> N;
    vector<int> L(N);
    int l;
    REP(i, 0, N){
        cin >> L[i];
    }
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = i+1; j < N; j++)
        {
            for (int k = j+1; k < N; k++)
            {
                if(L[i]!=L[j] && L[i]!=L[k] && L[j]!=L[k])
                if(L[i] + L[j] > L[k] && L[k] + L[j] > L[i] && L[i] + L[k] > L[j]) ++ans;
            }
            
        }
        
    }
    cout << ans << endl;
    

}

Measured memory_bytes: 3664
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

struct Node
{
	int C, S, F;
};

vector<Node> Nodes;

long long solve(int idx, int N)
{
	if (idx == N - 1)
	{
		return 0;
	}

	long long ans = Nodes[idx].S + Nodes[idx].C;

	for (int i = idx + 1; i < N - 1; i++)
	{
		if (ans < Nodes[i].S)
		{
			ans = Nodes[i].S;
		}

		if (ans % Nodes[i].F != 0)
		{
			ans += Nodes[i].F - (ans % Nodes[i].F);
		}

		ans += Nodes[i].C;
	}

	return ans;
}

int main()
{
	int N, c, s, f;
	cin >> N;

	Nodes.resize(N);

	for (int i = 0; i < N - 1; i++)
	{
		cin >> Nodes[i].C >> Nodes[i].S >> Nodes[i].F;
	}
	
	for (int i = 0; i < N; i++)
	{
		cout << solve(i, N) << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut res = 0;

    for i in 0..n {
        if i % 2 == 0 && a[i] % 2 == 1 {
            res += 1;
        }
    }

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


Measured memory_bytes: 2124
#include <stdio.h>
int main(){
	int a,b,c,d,e,f;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(a%d)e=a/d+1;
	else e=a/d;
	if(c%b)f=c/b+1;
	else f=c/b;
	if(e>=f)printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 1616
from collections import deque
import sys
sys.setrecursionlimit(10**8)
n = int(input())
graph = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = map(lambda x: int(x) - 1, input().split())
    graph[a].append(b)
    graph[b].append(a)
fennec = [10**5 + 10] * n
fennec[0] = 0
snuke = [10**5 + 10] * n
snuke[n - 1] = 0


def bfs(arr, q):
    while len(q) > 0:
        nex_q = []
        for qq in q:
            for nex in graph[qq[0]]:
                if arr[nex] > qq[1] + 1:
                    arr[nex] = qq[1] + 1
                    nex_q.append([nex, arr[nex]])
        q = nex_q[:]


sq, gq = deque(), deque()
sq.append([0, 0])
gq.append([n - 1, 0])
bfs(fennec, sq)
bfs(snuke, gq)
ans = 0
for i in range(n):
    if fennec[i] <= snuke[i]:
        ans += 1
    else:
        ans -= 1
# なんでans=>0じゃないん？？？？？？？？？？？？？？？？？？
# > 手番のプレイヤーがマスに色を塗ることができなかったとき、敗者となります。
# あー総合の数じゃなかったわ...
print("Fennec" if ans > 0 else "Snuke")


Measured memory_bytes: 33800
# coding: utf-8
N,M=map(int,input().split())
ans = 0
L = []
def UF(l):
    #親のノードを格納　2の親が4のとき par[2]=4
    par=[0]
    #木の深さを格納　根が2の深さが3の時 rank[2]=3
    rank=[0]
    
    #初期化
    for i in range(1,N+1):
        par.append(i)
        rank.append(0)
    
    #xの根を探す、同時に通過したノードすべてを根に直接つける
    def find(x):
        #xの親がxならば根なのでxを返す
        if par[x]==x:
            return x
        else:
            #違う場合は親の親を捜し自分の親にする
            par[x] = find(par[x])
            #再帰的に行うと根が見つかる
            return par[x]
    
    #xが属する木とyが属する木を併合する
    def unite(x,y):
        #根を探す
        root_x=find(x)
        root_y=find(y)
    
        #根が同じなら元からつながっているので終わり
        if root_x == root_y:
            return
    
        #ランクが大きい木の根の直下にランクが小さい木を結合
        if rank[root_x] < rank[root_y]:
            par[root_x] = root_y
    
        else:
            par[root_y] = root_x
    
        #ランクが等しいときのみランクが増える#なぜ#yにxが結合？
        if rank[root_x]==rank[root_y]:
            rank[root_x]+=1
    
    #xとyが同じ木に存在するかを調べる
    def same(x,y):
        return find(x)==find(y)
    for i in range(M-1):
        a = l[i][0]
        b = l[i][1]
        unite(a, b)
    for i in range(1, N):
        if not same(i, i+1):
            return True

#main
for i in range(M):
    L.append(list(map(int,input().split())))

for i in range(M):
    l = L[0:i] + L[i+1:]
    if UF(l):
        ans += 1
print(ans)

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n,m; cin >> n >> m;
  vector<pair<ll,ll>> p(n);
  rep(i,n){
    ll a,b; cin >> a >> b;
    p[i] = make_pair(a,b);
  }

  sort(p.begin(),p.end());
  /*cout << "sorted" << endl;
  for(auto x : p)
    cout << x.first << " " << x.second << endl;
  cout << "end" << endl;
  */
  ll ans = 0;
  ll num = 0;
  for(auto x : p){
    ll a = x.first;
    ll b = x.second;

    ans = num+b>=m ? ans+a*(m-num):ans+a*b;
    num += b;
    //cout << "a: " << a << " b: " << b << " ans: " << ans << " num: " << num << endl;
    if(num>=m) break;
  }

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


Measured memory_bytes: 4700
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
    string S,T;
    cin >> S;
    cin >> T;
    string Registr;
    Registr=T[T.length()-1];
    S+=Registr;
    if(S==T){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
	using namespace std;
ll n,m;
ll ans=0;
int main(){
	cin>>n>>m;
	if (m<=2*n) ans=(m/2);
	else ans=n+((m-2*n)/4);
	cout<<ans<<endl;
	return 0;
}

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

int main (){
  int r,c,N[101][101],M[101],sum=0,s[101];
  cin>>r>>c;
  for(int i=0;i<r;i++){
    for(int j=0;j<c;j++){
      cin>>N[i][j];
    }
  }
  for(int i=0;i<r;i++){
    for(int j=0;j<c;j++){
      M[i]+=N[i][j];
      s[j]+=N[i][j];
    }
    sum+=M[i];
  }

  for(int i=0;i<r;i++){
    for(int j=0;j<c;j++){
      cout<<N[i][j]<<" ";
    }
    cout<<M[i]<<endl;
  }
  for(int i=0;i<c;i++){
     cout<<s[i]<<" ";
  }
  cout<<sum<<endl;
  return 0;
}


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

int main(){
	int n, ans = 0;
	string s;
	cin >> n >> s;
	rep(i, 1000){
		int a1, a10, a100, temp = i;
		a1 = temp % 10;
		temp /= 10;
		a10 = temp % 10;
		temp /= 10;
		a100 = temp % 10;
		char c1, c10, c100;
		c1 = a1 + '0';
		c10 = a10 + '0';
		c100 = a100 + '0';
		int flag = 0;
		rep(j, s.size()){
			if(flag == 0 && s[j] == c100){
				flag++;
			}else if(flag == 1 && s[j] == c10){
				flag++;
			}else if(flag == 2 && s[j] == c1){
				ans++;
				break;
			}
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

const int kMod = 1000000007;

// a^n mod を計算する
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;
}

vector<ll> GetDivisors(ll x) {
  vector<ll> ret;
  for (ll i = 1; i * i <= x; ++i) {
    if (x % i == 0) {
      ret.push_back(i);
      if (x / i != i) ret.push_back(x / i);
    }
  }
  return ret;
}

// int gcd(int x, int y) {
//   if (x == 0) return y;
//   if (x > y) swap(x, y);
//   return gcd(y % x, x);
// }

int main() {
  int N, K;
  cin >> N >> K;
  vector<ll> count(K + 1);
  for (int i = 1; i <= K; ++i) {
    count[i] = modpow(K / i, N, kMod);
  }
  for (int i = K; i >= 1; --i) {
    for (auto x : GetDivisors(i)) {
      if (x == i) continue;
      count[x] = (count[x] - count[i] + kMod) % kMod;
    }
  }

  // vector<int> expected_count(K + 1);
  // for (int a = 1; a <= K; ++a) {
  //   for (int b = 1; b <= K; ++b) {
  //     int tmp = gcd(a, b);
  //     for (int c = 1; c <= K; ++c) {
  // 	expected_count[gcd(tmp, c)]++;
  //     }
  //   }
  // }
  
  ll ans = 0;
  for (int i = 1; i <= K; ++i) {
    ans = (ans + (count[i] * i) % kMod) % kMod;
  }
  cout << ans << endl;
  
  return 0;
}


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

int main(){
    long long n,k;
    cin >> n >> k;
    long long a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    long long res=1000000000;
    for(int i=0;i<=n-k;i++){
        res=min({res,abs(a[i])+abs(a[i+k-1LL]-a[i]),abs(a[i+k-1LL])+abs(a[i+k-1LL]-a[i])});
    }
    cout << res << endl;
}

Measured memory_bytes: 1024
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	int x,a;
	cin>>x>>a;
	if(x<a)	cout<<"0";
	else	cout<<10;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int A=0;
  cin >> N;
 
  for (int i = 0; i < N; i++) {
    int LO,LT;
    cin >>LO>>LT;
    A+=LT-LO+1;
    }
    cout<<A<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  int b;
  cin >> a >> b;
  int c =  a * b / 2;
  if (a * b > 2 * c){
    cout << "Odd";
  }else{
    cout << "Even";
  }
}

Measured memory_bytes: 3616
A = []
for i in range(3):
  A.append(list(map(int, input().split())))
N = int(input())
B = []
for i in range(N):
  B.append(int(input()))
for i in range(3):
  for j in range(3):
    A[i][j] = A[i][j] in B
for i in range(3):
  if A[i][0] and A[i][1] and A[i][2]:
    print("Yes")
    exit()
  if A[0][i] and A[1][i] and A[2][i]:
    print("Yes")
    exit()
if A[0][0] and A[1][1] and A[2][2]:
  print("Yes")
  exit()
if A[0][2] and A[1][1] and A[2][0]:
  print("Yes")
  exit()
print("No")

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

std::random_device rnd;
std::mt19937 mt(rnd());
std::uniform_int_distribution<> r(1, 26);

int D=365,c[26+1],last[26+1],M;

int main(){
    cin>>D;
    //input
    int s[D+1][26+1];
    for(int i=1;i<=26;i++)cin>>c[i];
    for(int i=1;i<=D;i++)for(int j=1;j<=26;j++)cin>>s[i][j];
    //output:random
    int t[D+1];
    for(int day=1;day<=D;day++){
        //greedy
        int max_type=0,max=-1000000000;
        for(int type=1;type<=26;type++){
            int score=s[day][type];
            for(int i=1;i<=26;i++)score-=c[i]*(day-last[i]);
            if(score>max)max=score,max_type=type;
            last[max_type]=day;
        }
        t[day]=max_type;
    }
    for(int i=1;i<=D;i++)cout<<t[i]<<endl;
    return 0;
}

Measured memory_bytes: 3676
n, a, b = list(map(int, input().split()))
x = list(map(int, input().split()))

ans = 0
for i in range(n-1):
    if (x[i+1]-x[i])*a > b:
        ans += b
    else:
        ans += (x[i+1]-x[i])*a

print(ans)


Measured memory_bytes: 14252
let () = Scanf.scanf "%d\n" @@ fun n ->
  let darr = Array.make (n+1) 0 in
  let dcum = Array.make (n+1) 0 in
  let sum = ref 0 in
  for i=1 to n do
    Scanf.scanf " %d" @@ fun d ->  darr.(i) <- d; dcum.(i) <- dcum.(i-1) + d
  done;
  for i=1 to n-1 do
    sum := !sum + darr.(i) * (dcum.(n) - dcum.(i))
  done;
  Printf.printf "%d\n" !sum


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

int main() {
    int W, H,x,y,r;
    cin >> W >> H >> x >> y >>r;
    if (x+r > W || x-r <0 || y+r > H || y-r<0) {
        cout << "No" <<endl;
    } else {
         cout << "Yes" <<endl;

    }
    return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define INF 1000000000000
typedef long long ll;

vector<string> str;

int main() {
	int n, ans[4] = { 0,0,0,0 };
	string temp, test[4] = { "AC","WA","TLE","RE" };
	cin >> n;
	REP(i, n) {
		cin >> temp;
		str.push_back(temp);
	}
	REP(i, n) {
		REP(j, 4) {
			if (str[i] == test[j]) {
				ans[j]++;
			}
		}
	}
	REP(i, 4) {
		cout << test[i] << " x " << ans[i] << endl;
	}
}

Measured memory_bytes: 7456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)x.size()
#define f first
#define s second
#define MAXN 2010

int D[MAXN][MAXN];
string S;
int N,M,ans;
vi same[MAXN];
vi diff[MAXN];
vi cur;
stack<pi> stk;

int main(){
	cin>>N>>M;
	for (int i=1;i<=N;++i){
		cin>>S;
		for (int j=1;j<=M;++j)D[i][j] = (S[j-1] == '#');
	}

	// for (int i=N;i>=1;--i){for (int j=1;j<=M;++j)cout<<D[i][j];cout<<'\n';}

	for (int i=1;i<M;++i)same[i].pb(N+1), diff[i].pb(N+1);
	for (int lower=N;lower>1;--lower){
		for (int i=1;i<M;++i){
			if (D[lower][i] == D[lower][i+1])same[i].pb(lower);
			else diff[i].pb(lower);
		}
	}

	for (int lower=1;lower<N;++lower){
		for (int i=1;i<M;++i)if (SZ(same[i]) && same[i].back() == lower)same[i].pop_back();
		for (int i=1;i<M;++i)if (SZ(diff[i]) && diff[i].back() == lower)diff[i].pop_back();
		
		stk.emplace(-1,0);
		for (int i=1;i<M;++i){
			// cout<<i<<'\n';
			// for (auto v:same[i])cout<<v<<' ';cout<<'\n';
			// for (auto v:diff[i])cout<<v<<' ';cout<<'\n';
			int fi = 0;
			// cout<<(D[lower][i] == D[lower][i+1])<<'\n';
			if (D[lower][i] == D[lower][i+1]){
				fi = diff[i].back();
			}else fi = same[i].back();
			fi = fi-lower;
			// cout<<"F "<<fi<<'\n';
			while (stk.top().f >= fi){
				pi c = stk.top();stk.pop();
				int st = stk.top().s+1;
				int en = i-1;
				int area = (en-st+2)*c.f;
				// cout<<st<<' '<<en<<' '<<area<<'\n';
				ans = max(ans, area);
			}
			stk.emplace(fi,i);
		}
		while (SZ(stk)){
			pi cur = stk.top();stk.pop();
			if (!SZ(stk))break;
			int st = stk.top().s+1;
			int en = M;
			int area = (en-st+1)*cur.f;
			// cout<<st<<' '<<en<<' '<<area<<'\n';
			ans = max(ans, area);
		}
		// cout<<lower<<' '<<ans<<'\n';
		// cout<<'\n';break;
	}
	cout<<max({N,M,ans});
}

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

long long teisuu=1000000000000000000;
int main() {
  long long n;
  cin >>n;
  vector<long long>a(n);
  for(long long i=0;i<n;i++){
    cin>>a[i];
    if(a[i]==0||a[i]>teisuu){
      cout<<0<<endl;
      return 0;
    }
  }
  long long kotae=a[0];
  for(long long i=1;i<n;i++){
    string s=to_string(a[i]);
    string t=to_string(kotae);
    if(s.size()+t.size()>20){
      cout<<-1<<endl;
      return 0;
    }
    kotae*=a[i];
    //cout<<kotae<<" "<<a[i]<<endl;
    if(kotae>teisuu||kotae<=0){
      cout<<-1<<endl;
      return 0;
    }
  }
  cout<<kotae<<endl;
  return 0;
}
    

Measured memory_bytes: 4052
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
import java.awt.Point;

public class Main {
    // static int INF = (1 << 30) - 1;
    // static long L_INF = (1L << 62) - 1;
    // static long MOD = (long) 1e9 + 7;

    static class Solver {
        void rec(int h, int w, boolean[][] visited, int[][] c) {
            if (visited[h][w] || c[h][w] == 0) {
                return;
            }
            visited[h][w] = true;
            for (int i = -1; i <= 1; i++) {
                for (int j = -1; j <= 1; j++) {
                    int y = h + i;
                    int x = w + j;
                    if (x >= 0 && y >= 0 && x < visited[0].length && y < visited.length) {
                        rec(y, x, visited, c);
                    }
                }
            }
        }

        // write your code
        void solve(InputReader in, PrintWriter out) {
            while (true) {
                int w = in.nextInt();
                int h = in.nextInt();
                if (w == 0 && h == 0) {
                    break;
                }
                int[][] c = new int[h][w];
                for (int i = 0; i < h; i++) {
                    for (int j = 0; j < w; j++) {
                        c[i][j] = in.nextInt();
                    }
                }
                boolean[][] visited = new boolean[h][w];
                int sum = 0;
                for (int i = 0; i < h; i++) {
                    for (int j = 0; j < w; j++) {
                        if (!visited[i][j] && c[i][j] == 1) {
                            rec(i, j, visited, c);
                            sum++;
                        }
                    }
                }
                out.println(sum);
            }
        }

        void debug(Object... os) {
            System.err.println(Arrays.deepToString(os));
        }
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

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

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

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

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



Measured memory_bytes: 27820
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    n, m, x = MII()
    aa = MII()
    l_c = sum([1 for a in aa if a < x])
    r_c = sum([1 for a in aa if a > x])
    print(min(l_c, r_c))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

long[100] WS, VS;

void main()
{
    auto nw = readln.split.to!(int[]);
    auto N = nw[0];
    auto W = nw[1];

    long[][] MEMO;
    MEMO.length = N;

    foreach (i; 0..N) {
        auto wv = readln.split.to!(long[]);
        WS[i] = wv[0];
        VS[i] = wv[1];
        MEMO[i].length = 10^^5+1;
    }

    long solve(int i, long v) {
        if (!v) return 0;
        if (i == N) return (long.max / 4) ;
        if (MEMO[i][v]) return MEMO[i][v];
        return MEMO[i][v] = min(
            solve(i+1, v),
            v < VS[i] ? (long.max / 4) : solve(i+1, v-VS[i]) + WS[i]
        );
    }

    foreach_reverse (v; 0..10^^5+1) {
        if (solve(0, v) <= W) {
            writeln(v);
            return;
        }
    }
}

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

int main() {
    ll n,a,b,med1,med2;
    vector<ll>V1,V2;
    cin >> n;
    for (int i=0;i<n;i++) {
        cin >> a >> b;
        V1.push_back(a);
        V2.push_back(b);
    }
    sort(V1.begin(),V1.end());
    sort(V2.begin(),V2.end());
    if (n%2==1) {
        med1=V1[n/2];
        med2=V2[n/2];
        cout << med2-med1+1;
    }
    else {
        med1=(V1[n/2-1]+V1[n/2]);
        med2=(V2[n/2-1]+V2[n/2]);
        cout << med2-med1+1;
    }
}


Measured memory_bytes: 6560
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if(b<10){
        for(int i=2;i*i<=a*10+b;i++){
            if(i*i==a*10+b){
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
        return 0;
    }
    else if(b<100){
        for(int i=2;i*i<=a*100+b;i++){
            if(i*i==a*100+b){
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
        return 0;
    }
    else{
        for(int i=2;i*i<=a*1000+b;i++){
            if(i*i==a*1000+b){
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
        return 0;
    }        
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int ans = 0;
  int counter =0;
  for (int i=1; i <= N; i++){
    int K = i;
    int tempAns = 0;
    while(K > 1){
      if (K%2 == 0){
        K /= 2;
        tempAns++;
      }
      else break;
    }
    if (tempAns > counter) counter = tempAns;
  }
  ans = pow(2, counter);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3992
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let (L, R) = (input[0], input[1])
var ans = 2019
loop: for i in L..<R {
  for j in i+1...R {
    ans = min((i*j)%2019, ans)
    if ans == 0 {
      break loop
    }
  }
}
print(ans)

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

int main() {
  int n;
  double ans = 0;
  cin >> n;
  vector<int> a(n);
  rep(i ,n) {
    cin >> a[i];
  }
  rep(i,n) {
    ans += (double)1 / a[i];
  }
  ans = (double)1 / ans;
  cout << fixed << ans << setprecision(5) << endl;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
if K%2==1:
    s=N//K
    print(s**3)
    exit()
k=K//2
s=N//k
num=0
if s%2==0:
    print((s**3)//4)
    exit()
t=((s//2+1)**2)*(s//2+1)
u=((s//2)**2)*(s//2)
print(t+u)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define ff first
#define ss second
#define pb push_back
#define N 505

#define mod 998244353

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin >> n;
	int a[n], max = 0, pos = 0, k = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		if(a[i] > max)
			max = a[i], pos = i;
	}

	for (int i = 0; i < n; ++i)
	{
		if(a[i] == max)
			k++;
	}

	if(k > 1)
	{
		for (int i = 0; i < n; ++i)
		{
			cout << max << "\n";
		}
	}
	else
	{
		for (int i = 0; i < n; ++i)
		{
			if(i != pos)
				cout << max << "\n";
			else
			{
				a[pos] = 0;
				int ans = 0;
				for (int i = 0; i < n; ++i)
				{
					if(ans < a[i])
						ans = a[i];
				}
				cout << ans << "\n";
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i=0; i<(int)(n); i++)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1001001001
typedef long long ll;

int main() {
    ll h, n;
    cin >> h >> n;
    vector<ll> vec(h+1, INF);
    vec[0] = 0;
    REP(i, n){
        ll a, b;
        cin >> a >> b;
        REP(j, h){
            ll checkpoint;
            if(j+a <= h){
                checkpoint = j+a;
            }else{
                checkpoint = h;
            }
            vec[checkpoint] = min(vec[checkpoint], vec[j]+b);
        }
    }
    cout << vec[h] << endl;
    return 0;
}

Measured memory_bytes: 384
import itertools

n,a,b,c=(input().split())
n,a,b,c=int(n),int(a),int(b),int(c)
l=[int(input()) for i in range(n)]
#print(n,a,b,c,l)

ansans=float('inf')
ans=float('inf')

mylist=list(itertools.product(range(4),repeat=n))
#print(len(mylist))
#mylist=[1,2,2,2,3]
for j in range(len(mylist)):
    x,y,z=0,0,0
    for i in range(n):
        if mylist[j][i]==1:
            x+=l[i]
        elif mylist[j][i]==2:
            y+=l[i]
        elif mylist[j][i]==3:
            z+=l[i]
        
    if mylist[j].count(1)>0 and mylist[j].count(2)>0 and mylist[j].count(3) > 0:
        ans=0
        ans+=abs(a-x)+abs(b-y)+abs(c-z)
        compo=0
        for i in range(1,4):
            compo+=mylist[j].count(i)-1
        ans+=10*compo

    if ans < ansans:
        ansans = ans

print(ansans)


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

ll a, b, n, c1, c2, ans = 0;

ll f(ll x) { return floor(a * x / b) - a * floor(x / b); }

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

  cout << f(min(b - 1, n)) << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	string a, b, c;
	cin >> a >> b >> c;
	if ((a[a.length() - 1] == b[0]) && (b[b.length() - 1] == c[0])) cout << "YES";
	else cout << "NO";

	return 0;
}


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

void solve() {
    string S;
    cin >> S;
    if (S[2] == S[3] && S[4] == S[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string S;
    cin >> S;
    if(S == "AKIHABARA" || S == "AKIHABAR" || S == "AKIHABRA" ||
       S == "AKIHBARA" || S == "KIHABARA" || S == "AKIHABR" ||
       S == "AKIHBAR" || S == "KIHABAR" || S == "AKIHBRA" ||
       S == "KIHABRA" || S == "KIHBARA" || S == "KIHBRA" ||
       S == "KIHBAR" || S == "KIHABR" || S == "AKIHBR" ||
       S == "KIHBR") {
      cout << "YES" << endl;
      return 0;
    }
   cout << "NO" << endl;
}



Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int a,b,ans;
int main()
{
	cin>>a>>b;
	if(a<b)
	 swap(a,b);
	ans+=a;
	ans=ans+max(a-1,b);
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int solve(string s){
	vector<int> list;
	int dg;
	int flag=1;
	int ind;
	int r_cnt=0;
	while(flag){
		flag=1;
		for(int i=0;i<s.size();i++){
			//cout<<"in roooop: "<<r_cnt<<endl;
			if(i==0){
				r_cnt++;
			}
			if(s[i-1]=='['&& s[i]!='[' && s[i]!=']'){
					//cout<<"push vector"<<endl;
					if(list.size()==0){
						ind=i-1;
					}
					int cmp=0;
					while(s[i]!=']'){
						cmp*=10;
						cmp+=s[i]-'0';
						i++;
					}
					//cout<<"cmp: "<<cmp<<endl;
					list.push_back(cmp);
					if((s[i]==']' && s[i+1]==']') || i==s.size()-1){
						if(i==s.size()-1 && list.size()==1){
							flag=0;
							break;
						}
						sort(list.begin(),list.end());
						//cout<<"list elements"<<endl;
						/*for(int j=0;j<list.size();j++){
							cout<<list[j]<<endl;
						}*/
						dg=0;
						if(r_cnt==1){
							for(int j=0;j<list.size()/2+1;j++){
								dg+=list[j]/2+1;
							}
						}
						else{
							for(int j=0;j<list.size()/2+1;j++){
								dg+=list[j];
							}
						}
						list.clear();
						//cout<<"Let's vote!"<<" We need: "<<dg<<endl;
						int cp_dg=dg;
						string rpl;
						int div=10;
						while(cp_dg){
							char c=((cp_dg%div)/(div/10))+'0';
							rpl.push_back(c);
							cp_dg-=cp_dg%div;
							div*=10;
						}
						reverse(rpl.begin(),rpl.end());
						s.replace(ind,(i-ind)+1,rpl);
						i=ind+rpl.size();
						//cout<<"new string is: "<<s<<endl;
					}
			}
		}
	}
	return dg;
}

int main(){
	string S;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>S;
		//cout<<"input: "<<S<<endl;
		int ans=solve(S);
		//cout<<"func solve"<<endl;
		cout<<ans<<endl;
	}
	return 0;
}




Measured memory_bytes: 3248
fn main(){
  proconio::input!{x:i32,n:usize,p:[i32;n]};
  let mut ans=-200;
  for i in 0..102{
    if p.contains(&i){continue}
    if (i-x).abs()<(ans-x).abs(){
      ans = i
    }
  }
  println!("{}",ans)
}

Measured memory_bytes: 2140
import java.util.*;
// warm-up
// And the performance is...
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int R = sc.nextInt(), G = sc.nextInt();
		System.out.println((2*G)-R);
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 35692
a,b,k=map(int,input().split())
if 2*k>=b-a+1:
  for i in range(a,b+1):
    print(i)
else:
  for i in range(a,a+k):
    print(i)
  for i in range(b-k+1,b+1):
    print(i)


Measured memory_bytes: 3060
import scala.io.StdIn.{readLine,readInt}

object Main extends App {
  val n = (1 to readInt).toArray
  val m = readInt
  for(i <- 1 to m) {
    val h = readLine.split(",").map(_.toInt)
    val temp = n(h(0)-1)
    n(h(0)-1) = n(h(1)-1)
    n(h(1)-1) = temp
  }
  n.foreach(println)
}

Measured memory_bytes: 43720
#include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cctype>
#include<cstring>
#include<utility>
#include<cmath>
using namespace std;


int main() {
    int n, k, num = 1, count = 0;
    cin >> n >> k;

    while (num <= k && count < n) {
        num *= 2;
        count += 1;
    }

    cout << num + k*(n - count) << endl;

    return 0;
}

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

int main() {
	/****input****/
  int n;
  cin >> n;
  string s,t;
  cin >> s >> t;

  /****calc****/
  string ans = "\0";

  for(int i = 0; i < n; i++){
	  ans += s[i];
	  ans += t[i];
  }

  /****output****/
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
n, m = map(int, input().split())
a_list = []
for i in range(n):
	a_list.append(input())
b_list = []
for i in range(m):
	b_list.append(input())
b = ''.join(b_list)
r = 'No'
end = n - m if n - m > 0 else 1
for i in range(end):
	a =	''.join(list(map(lambda a: a[:m], a_list)))
	if b in a:
		r = 'Yes'
		break
print(r)

Measured memory_bytes: 38640
N,D = map(int,input().split())
grid = []
for i in range(N):
  array = list(map(int,input().split()))
  grid.append(array)

  ans = 0
for i in range(N):
  if grid[i][0]**2 + grid[i][1]**2 <= D**2:
    ans = ans + 1

print(ans)



Measured memory_bytes: 45320
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
def zeros(n): return [0]*n

INF = 10**18

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                w = cmt + ': ' + str(x)
            else:
                w = str(x)
            print(w)
        return x

def prob():
    d = Debug()
    d.off()
    A, B, C = getIntList()
    d.dmp((A, B, C),'A, B, C')
    if A == B and B == C:
        return 'Yes'
    else:
        return 'No'


ans = prob()
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int a[100001];
int save=0;
bool first,second;
int main()
{
    int n,q;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    cin>>q;
    for(int i=0;i<q;i++)
    {
        int index;
        cin>>index;
        second=first=false;
        for(int j=save;j<n;j++)
        {
            if(a[j]>=index&&first==false)
            {
                cout<<j;
                first=true;
            }
            if(a[j]>index&&first==true)
            {
                cout<<" "<<j<<endl;
                second=true;
                save=j;
                break;
            }
        }
        if(first==false)
            cout<<n;
        if(second==false)
            {
                cout<<" "<<n<<endl;
                save=n;
            }
    }
    return 0;
}



Measured memory_bytes: 3476