akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int A, B, C, D; cin >> A >> B >> C >> D;
	int S1 = A*B;
	int S2 = C*D;
	int res = max(S1, S2);
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
char a[1000];
int ans=0,b[7],i,j=0,k=0,x=1,l;
while(scanf("%s\n",a)!=EOF){
for(i=0;;i++){
if(k==1 && '0'<=a[i] && a[i]<='9'){
b[j]=a[i]-'0';
j++;
}
else if('0'<=a[i] && a[i]<='9'){
b[j]=a[i]-'0';
k=1,j++;
}
else if(k==1){
k=0;
for(l=j-1;l>=0;l--){
ans=ans+x*b[l];
x=x*10;
}
x=1,j=0;
}
if(a[i]=='\0'){
break;
}
}
}
printf("%d\n",ans);
return 0;
}


Measured memory_bytes: 2048
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <numeric>
#include <type_traits>
#include <limits>
#include <random>
#include <iomanip>

using namespace std;

using ll = long long;

typedef pair<int, int> P;

#define rep(i,N) for(long long i = 0;i < (long long)N; ++i)

static int mod = 1000000007;
static int large = 1000000000;

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

int a, b, c;

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

	if (b / a < c) {
		cout << b / a << endl;
	}
	else {
		cout << c << endl;
	}
	return 0;
}

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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);
const long long MOD = 1000000007;

template <class T, class S>
using umap = std::unordered_map<T, S>;
using ll = long long;
using namespace std;

int main() {
    ll n;
    ll p[200010];
    vector<ll > v;
    string s;
    ll div = 1000000000000000000;
  
    cin >> n;

    REP(i, n){
        ll tmp;
        cin >> tmp;
        v.PB(tmp);
    }

    sort(ALL(v));

    if (v[0] == 0){
        cout << 0 << endl;
    } else {
        ll mul = v[0];
        REP(i, n-1){
            if (mul > div/v[i+1]){
                cout << -1 << endl;
                return 0;
            } else {
                mul *= v[i+1];
            }
        }

        cout << mul << endl;
    }

    return 0;
}

Measured memory_bytes: 4280
#include<iostream>
    using namespace std;
    main(){
      int n, x = 0;
      cin>>n;
      for(int i = 1; i <= n; i++){
        int j = i, z = 0;
        while(j > 0){
          z++;
          j /= 10;
        }
        if(z & 1) x++;
      }
      cout<<x;
    }

Measured memory_bytes: 256
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

#define endl "\n"

void solve() {
    cini(n);
    n=!n;
    cout<<n<<endl;
}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


Measured memory_bytes: 3588
#include<iostream>
#include<string>

int main(){

    size_t n;
    std::string s, t;
    std::cin >> n >> s >> t;

    for(size_t i = 0; i < n; i++){
        std::cout << s.at(i) << t.at(i);
    }std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args){
        // input N
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int ANS = 0;
        String S = sc.next();
        for (int i =0;i < N; i ++){
            if ('W' == S.charAt(i)){
                ANS += 1;
            }
        }
      	int kiri = N - ANS;
        String SS = S.substring(kiri);
        long len = SS.length();
        for(int j = 0; j < len;j++){
            if ('W' == SS.charAt(j)){
                ANS -= 1;
            }
        }
        System.out.println(ANS);
        
    }
}

Measured memory_bytes: 41040
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int MOD = 1e9+7;
const ll LINF = 1e18;
const int INF = 1e9;
unsigned ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

int main()
{
    B = 1;
    cin >> N;
    vector<ll> arr(N);
    for (int i = 0; i < N; i++) 
    {
        cin >> arr[i];
        if(arr[i] == 0)
        {
            cout << 0;
            return 0;
        }
    }
    for (int i = 0; i < N; i++) 
    {
        C = B*arr[i];

        // if((log10(B)+log10(arr[i])) >= 17)
        // {
        //     cout << "-1";
        //     return 0;
        // }
        // if(B>= 1000000000000000001/arr[i])
        // {
        //     cout << "-1";
        //     return 0;
        // }

        if(C > 1000000000000000000)
        {
            cout << "-1";
            return 0;
        }
        if(C/B != arr[i])
        {
            cout << "-1";
            return 0;
        }
        B *=arr[i];


        
        
    }
    if(B > 1000000000000000000)
        {
            cout << "-1";
            return 0;
        }

    cout << B;

    return 0;
}

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

using namespace std;

int main()
{
    int n,m,x,y;
    cin >> n >> m >> x >> y;

    vector<int> xi(n+1);
    vector<int> yi(m+1);
    xi[0]=x;
    yi[0]=y;
    for(int i=1;i<n+1;i++) cin >> xi[i];
    for(int i=1;i<m+1;i++) cin >> yi[i];
    
    sort(xi.begin(),xi.end());
    sort(yi.begin(),yi.end());

    if(xi[n] < yi[0]) cout << "No War" << endl;
    else cout << "War" << endl;
}

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

int n,a[maxn];

int main(){
    while(scanf("%d",&n)==1){
        for(int i=0;i<n;++i) scanf("%d",&a[i]);
        sort(a,a+n);
        long long ans=0;
        for(int i=0;i<n;++i){
            for(int j=i+1;j<n;++j){
                int le=a[j]-a[i],ri=a[i]+a[j];
                int pl=upper_bound(a,a+n,le)-a;
                int pr=lower_bound(a,a+n,ri)-a;
                int cnt=pr-pl;
                if(pl<=i && i<pr) --cnt;
                if(pl<=j && j<pr) --cnt;
                //printf("(%d,%d),(%d,%d),cnt=%d\n",i,j,pl,pr,cnt);
                ans+=cnt;
            }
        }
        printf("%lld\n",ans/3);
    }
    return 0;
}

Measured memory_bytes: 256
a=int(input())
b=[int(input()) for i in range(a)]
b.sort()
ans=sum(b)
d=0
for i in range(a):
	if b[i]%10!=0 and sum(b)%10==0 :
		ans=sum(b)-b[i]
		d=1
		break
if d==1 or ans%10!=0:
	print(ans)
else:
	print(0)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const int MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
    int q;
    cin >> q;
    deque<int> a;
    vector<int> ans;
    rep(i, q){
        int n, d, x, p;
        cin >> n;
        switch(n){
        case 0:
            cin >> d >> x;
            if(d==0)a.push_front(x);
            else a.push_back(x);
            break;
        case 1:
            cin >> p;
            ans.push_back(a[p]);
            break;
        default:
            cin >> d;
            if(d==0)a.pop_front();
            else a.pop_back();
            break;
        }
    }
    int N = ans.size();
    rep(i, N) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 4604
package main

import "fmt"

var (
	n, k int
)

func main() {
	fmt.Scan(&n, &k)

	x := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&x[i])
	}

	f(x)
	fmt.Println(sum(x))

}

func f(x []int) {
	for i, v := range x {
		if v <= abs(k-v) {
			x[i] = 2 * v
		} else {
			x[i] = abs(k-v) * 2
		}
	}
}

func abs(x int) int {
	if x < 0 {
		return -x
	}

	return x
}

func sum(x []int) int {
	if len(x) == 0 {
		return 0
	}

	return x[0] + sum(x[1:])
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
void fl(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
int main(){
	fast;
	ll n;
	cin>>n;
	ll a[n+1];
	rp(i,1,n){
		cin>>a[i];
		if(a[i]%2==0){
		if(a[i]%2==0&&(a[i]%3==0||a[i]%5==0))continue;
		else return cout<<"DENIED"<<endl,0;
	}
	}cout<<"APPROVED"<<endl;
	return 0;
}/*『你强归你强，Siyuan比你强』*/





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int M,D;
  int S=0;
  cin>>M>>D;
  for(int X=1;X<=M;X++){
    for(int Y=22;Y<=D;Y++){
      if((Y/10)*(Y%10)==X&&Y%10>1){
        S++;
      }
    }
  }
  cout<<S<<endl;
}


Measured memory_bytes: 3572
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	m := getNextInt(scanner)
	k := getNextInt64(scanner)
	bb := make([]int64, m+1)
	aa := make([]int64, n+1)
	for i := 0; i < n; i++ {
		aa[i+1] = aa[i] + getNextInt64(scanner)
	}
	for i := 0; i < m; i++ {
		bb[i+1] = bb[i] + getNextInt64(scanner)
	}
	var ans int
	for i := 0; i < n+1; i++ {
		l := -1
		r := m + 1
		for l+1 < r {
			mid := (l + r) >> 1
			if aa[i]+bb[mid] > k {
				r = mid
				continue
			}
			l = mid
		}
		if l == -1 {
			continue
		}
		if ans < i+l {
			ans = i + l
		}
	}
	fmt.Fprintln(writer, ans)
}


Measured memory_bytes: 10412
package main

import "fmt"

func main(){
	var n,m int;
	fmt.Scan(&n,&m)
	s := make([]int,m)
	c := make([]int,m)
	var temp_s,temp_c int
	ans := true
	for i := 0 ; i < m ; i++ {
		fmt.Scan(&temp_s,&temp_c)
		for j := 0; j < i ; j++ {
			if temp_s == s[j] && temp_c != c[j] {
				ans = false
				break
			}
		}
		if ans == true {
			s[i] = temp_s
			c[i] = temp_c
		} else {
			break
		}
	}
	if m == 0 {
		if n == 1 {
			fmt.Println("0")
		} else if n == 2 {
			fmt.Println("10")
		} else {
			fmt.Println("100")
		}
	} else if ans {
		if n == 1 {
			for j := 0 ; j < m ; j++ {
				if s[j] == 1 {
					fmt.Println(c[j])
					break
				}
			}
		} else if n == 2{
			one := 0
			ten := -1
			for j := 0 ; j < m ; j++ {
				if s[j] == 1 {
					ten = c[j]
				} else if s[j] == 2 {
					one = c[j]
				}
			}
			if ten == 0 {
				fmt.Println("-1")
			} else if ten > 0 {
				fmt.Println(ten*10 + one)
			} else {
				fmt.Println(10+one)
			}
		} else {
			one := 0
			ten := 0
			hun := -1
			for j := 0 ; j < m ; j++ {
				if s[j] == 1 {
					hun = c[j]
				} else if s[j] == 2 {
					ten = c[j]
				} else if s[j] == 3 {
					one = c[j]
				}
			}
//fmt.Println(hun,ten,one)
			if hun == 0 {
				fmt.Println("-1")
			} else if hun > 0 {
				fmt.Println(hun*100+ten*10+one)
			} else {
				fmt.Println(100+ten*10+one)
			}
		}
	} else {
		fmt.Println("-1")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using vi=vector<int>;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }

//mod逆元を使ったnCkの計算(速)
const int64_t MAX = 3000010;
const int64_t MOD = 1000000007;
 
int64_t fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 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;
  }
}
 
// 二項係数計算
int64_t COM(int64_t n, int64_t k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
//繰り返し二乗法
int64_t powmod(int64_t x, int64_t n) { 
  int64_t ans = 1;
  while (n > 0) {
    if ((n & 1) == 1) {
      ans = ans * x;
      ans %= MOD;
    }
    x = x * x;//一周する度にx, x^2, x^4, x^8となる
    x %= MOD;
    n >>= 1; //桁をずらす n = n >> 1
  }
  return ans;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int64_t n,k;
    cin >> n >> k;
    COMinit();
    rep(i,k){
        int64_t x=COM(n-k+1,i+1);
        int64_t y=COM(k-1,i);
        int64_t ans = (x%MOD)*(y%MOD);
        ans=ans%MOD;
        cout << ans << "\n";
    }
    return 0;
}   

Measured memory_bytes: 73948
def get_ints():
  return list(map(int,input().split()))

n = int(input())
a,b = [],[]
for i in range(n):
  x,y = get_ints()
  a.append(x+y)
  b.append(x-y)

a.sort()
b.sort()
ans = max(a[-1]-a[0], b[-1]-b[0])
print(ans)





Measured memory_bytes: 25460
use std::io::*;

fn inv(mut x: usize, m: usize) -> usize {
    let mut e = m - 2;
    let mut res = 1;
    while e > 0 {
        if e & 1 == 1 {
            res = res * x % m;
        }
        x = x * x % m;
        e >>= 1;
    }
    res
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let p: usize = itr.next().unwrap().parse().unwrap();
    let s: Vec<usize> = itr
        .next()
        .unwrap()
        .chars()
        .map(|c| c as usize - '0' as usize)
        .collect();

    let mut ans: usize = 0;
    if p == 2 {
        for i in 0..n {
            if s[i] % 2 == 0 {
                ans += i + 1;
            }
        }
    } else if p == 5 {
        for i in 0..n {
            if s[i] % 5 == 0 {
                ans += i + 1;
            }
        }
    } else {
        let mut memo: Vec<usize> = vec![0; p + 1];
        let mut now = 0;
        let mut ten = 1;
        let teninv = inv(10, p);
        memo[0] = 1;
        for i in 0..n {
            now = (now * 10 + s[i]) % p;
            ten = ten * teninv % p;
            ans += memo[now * ten % p];
            memo[now * ten % p] += 1;
        }
    }
    println!("{}", ans);
}


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

void show(int n, int *a){
    int k;
    for (k = 0; k < n - 1; k++){
        printf("%d ", a[k]);
    }
    printf("%d\n", a[n - 1]);
}

int main(void){
    int n;
    int *a;
    int i, j;
    int tmp;
    scanf("%d", &n);
    a = (int *)malloc(sizeof(int) * n);
    for (i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }

    for (i = 1; i < n; i++){
        tmp = a[i];
        j = i - 1;
        show(n, a);
        while (tmp < a[j] && j >= 0){
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = tmp;     
    }
    show(n, a);
    return 0;
}

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

using namespace std;

int main()
{
    long long N, x, ans = 0, i, baki, khabo, s, r;
    cin >> N >> x;
    long long a[N];
    for(i = 0; i < N; i++) {
        cin >> a[i];
    }
    for(i = 1; i < N; i++) {
        if(a[i] + a[i-1] > x) {
            s = a[i] + a[i-1];
            r = s - x;
            ans+= r;
            khabo = min(a[i], r);
            a[i]-= khabo;
//            r-= khabo;
//            if(r > 0) {
//               a[i-1]-= r;
//            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 4388
N = int(input())

XY = []
for _ in range(N):
    A = int(input())
    tmp = []
    for _ in range(A):
        x, y = map(int, input().split())
        tmp.append((x - 1, y))
    XY.append(tmp)


def judge(bit):
    for i in range(N):
        if not (bit & (1 << i)):
            continue
        for x, y in XY[i]:
            if y == 1 and (not (bit & (1 << x))):
                return False
            if y == 0 and (bit & (1 << x)):
                return False
    return True


ans = 0
for bit in range(1 << N):
    if (judge(bit)):
        # print('bit', bit, bin(bit))
        cnt = 0
        for i in range(N):
            if (bit & (1 << i)):
                cnt += 1
        ans = max(ans, cnt)
print(ans)


Measured memory_bytes: 3064
// You got a dream , you gotta protect it .
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
typedef long long ll;
typedef long double ld;
const long double EPS = 1e-6;
const long double pi = acos(-1);
const int INF = 1e9 + 10;
int main(){
    FAST
    ll k , x;
    cin >> k >> x;
    ll r = k * 500;
    if(r >= x)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j]
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
int main(){
    string s,t; cin >> s >> t;
    cout << t+s << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int Max(int *A, int *B){
  if(*A > *B){
    (*A)--;
    return *A + 1;
  }else{
    (*B)--;
    return *B + 1;
  }
}

int MAX(int A, int B){
  int X;
  X = 0;
  X += Max(&A, &B);
  X += Max(&A, &B);
  return X;
}

int main(void){
  int A, B;
  scanf("%d %d", &A, &B);
  printf("%d\n", MAX(A, B));
  return 0;
}


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v)                                                            \
  do {                                                                         \
    x = max(x, v);                                                             \
  } while (0)
#define chmin(x, v)                                                            \
  do {                                                                         \
    x = min(x, v);                                                             \
  } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

ll N, M;
vector<ll> x(200000,0); // 点の間のパリティ差分行列
vector<bool> walked(200000,false);
/*
 * N=3のとき
 *   a0  a1  a2
 * x0  x1  x2  x3
 */
struct E {
  ll eID; // コードのID
  ll nxt; // 次の頂点
};
vector<vector<PLL>> edges(200000); // first: 次の頂点、 second: 辺のID
vector<ll> ans;

// vID以下をDFSで探索
// vID以下の部分木のパリティ合計を返す
ll dfs(ll vID) {
  walked[vID] = true;
  ll res = x[vID];
  for(auto e: edges[vID]) {
    if (walked[e.first])
      continue;
    // 部分木のパリティが1であればその辺を加える
    ll r = dfs(e.first);
    if (r) {
      ans.push_back(e.second);
      res ^= r;
    }
  }
  return res;
}

signed main() {
  cin >> N >> M;
  vector<PLL> p(N); // p[i].first: i番目の点の座標、p[i].second: i番目の点がONかどうか
  rep(i, N) {
    cin >> p[i].first >> p[i].second;
  }
  // 点を座標昇順で並べておく
  sort(begin(p), end(p));
  // パリティ差分行列
  x[0] = p[0].second;
  x[N] = p[N-1].second;
  for (ll i=1; i<N; i++) {
    x[i] = p[i].second ^ p[i-1].second;
  }
  //rep(i, N+1){
  //  cout << x[i] << " ";
  //}
  //cout<<endl;
  for (ll eID = 1; eID <= M; eID++) {
    ll l, r;
    cin >> l >> r;
    ll vID1 = lower_bound(begin(p), end(p), PLL(l,0)) - begin(p); // 頂点と同じ座標の場合はそれを含む
    ll vID2 = upper_bound(begin(p), end(p), PLL(r,1)) - begin(p); // 頂点と同じ座標の場合はその右側
    edges[vID1].push_back(PLL(vID2, eID));
    edges[vID2].push_back(PLL(vID1, eID));
    //printf("l=%d r=%d vID1=%d vID2=%d\n", l, r, vID1, vID2);
  }

  // DFS
  for (ll vID = 0; vID <= N; vID++) {
    if (walked[vID])
      continue;
    if (dfs(vID)) {
      //printf("dfs(%d)=%d\n", vID, 1);
      cout << -1 << endl;
      return 0;
    }
  }

  //cout << "ans:" << endl;
  sort(begin(ans),end(ans));
  cout << ans.size() << endl;
  for (auto eID : ans) {
    cout << eID << " ";
  }
  cout << endl;
}


Measured memory_bytes: 24956
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var HW = ReadLongArray();
            var mul = HW[0] * HW[1];
            if (HW[0] == 1 || HW[1] == 1)
            {
                Console.WriteLine(1);
                return;
            }
            if (mul % 2 == 0)
            {
                Console.WriteLine(mul / 2);
            }
            else
            {
                Console.WriteLine((mul + 1) / 2);
            }
        }


        private static readonly Func<string> Read = () => Console.ReadLine();
        private static readonly Func<string[]> ReadStringArray = () => Console.ReadLine().Split();
        private static readonly Func<int> ReadInt = () => int.Parse(Console.ReadLine());
        private static readonly Func<long> ReadLong = () => long.Parse(Console.ReadLine());
        private static readonly Func<int[]> ReadIntArray = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
        private static readonly Func<long[]> ReadLongArray = () => Console.ReadLine().Split().Select(long.Parse).ToArray();
        private static readonly Action<string> Cw = str => Console.WriteLine(str);
    }
}

Measured memory_bytes: 13396
#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 H, W;
  cin >> H >> W;
  string s[H];
  REP(i, H) cin >> s[i];

  auto d = vector<tuple<int, int> >();
  // https://cpprefjp.github.io/lang/cpp11/range_based_for.html
  for (auto dx : {1, 0, -1}) {
    for (auto dy : {1, 0, -1}) {
      if (dx == 0 && dy == 0) continue;
      d.push_back(make_tuple(dx, dy));
    }
  }

  // print debug & unpack
  for (auto &t : d) {
    int dx, dy;
    std::tie(dx, dy) = t;
    // cout << dx << ',' << dy << endl;
  }

  char c[H][W];
  REP(i, H) {
    REP(j, W) {
      if (s[i][j] == '#') {
        c[i][j] = '#';
      } else {
        int b = 0;
        for (auto &_d : d) {
          int x = j + get<0>(_d), y = i + get<1>(_d);
          if (0 <= x && x < W && 0 <= y && y < H && s[y][x] == '#') b++;
        }
        c[i][j] = b + '0';
      }
    }
  }

  REP(i, H) {
    REP(j, W) cout << c[i][j];
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
n = int(readline())
m = map(int,read().split())
xl = zip(m,m)
c = [(x-l,x+l) for x,l in xl]
  
from operator import itemgetter
c.sort()
c.sort(key=itemgetter(1))

ans = 1
chk = c[0][1]
for i,j in c:
  if i >= chk:
    ans +=1
    chk = j
    
print(ans)

Measured memory_bytes: 27800
#include<iostream>
using namespace std;
int main(){
 long a[21];
 a[0] = 1;
 for (int i = 1;i <= 20;i++){
   a[i] = a[i - 1] * i;
 }
  int n;
  cin >> n;
  cout << a[n] << endl;
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main(){
  cout<<fixed<<setprecision(12);
  double a,b,c;
  cin>>a>>b>>c;
  double PI=acos(-1.0);
  c=c/180.0*PI;
  cout<<a*b*sin(c)/2.0<<endl;
  double cc=a*a+b*b-2*a*b*cos(c);
  cout<<a+b+sqrt(cc)<<endl;
  cout<<b*sin(c)<<endl;
  return 0;
}



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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed up
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed down
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed down
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(15);

    vi n26 = {1};
    rep(i, 12) n26.push_back(n26[i]*26);

//    for(auto val : n26) debug(val);  // ok

    i64 n; cin >> n;
    i32 len = 1;
    i64 p = 1;
    while(1) {
        if(p <= n && n <= p*26) break;
        p = p*26+1;
        ++len;
    }
//    debug(len);  // ok

    string s;
    n = n-p;
    --len;
    while(len >= 0) {
        i64 tmp = n26[len];
        i64 x = n/tmp;
        s.push_back('a' + x);

        n = n%tmp;
        --len;
    }

    cout << s << '\n';


    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 3644
#include <stdio.h>

int main(void) {

	int a,b,c,d;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	scanf("%d", &d);
	if(a+b+c+d != 1+9+4+7){
		printf("NO");
		return 0;
	}
	if(a*b*c*d != 1*9*4*7){
		printf("NO");
		return 0;
	}
	printf("YES");
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
    int N;
    cin >> N;
    int V[N], C[N];
    for(int i = 0; i < N; i++) {
        cin >> V[i];
    }
    for(int i = 0; i < N; i++) {
        cin >> C[i];
    }
    // int X[N], Y[N];
    int cost = 0;
    for(int i = 0; i < N; i++) {
        int tmpX = V[i] - C[i];
        if(tmpX > 0) {
            cost += tmpX;
        }
    }
    cout << cost << endl;
    return 0;
}

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

int main() {
int N,x;
cin>>N;
int cnt = 0;
for(int i = 0;i<N;i++){
cin>>x;
int j = 0;
while(x%2!=1){
x /=2;
j++;}
if(i==0){
cnt=j;}
if(cnt>j){
cnt=j;}
}
cout<<cnt;
}


Measured memory_bytes: 3596
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>

using namespace std;

/*
*   最大公約数と最小公倍数
*/
using namespace std;
typedef long long int ll;

// 最大公約数
ll GCD(ll a, ll b){
    if(a < b) swap(a, b);
    // a > b
    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

// 最小公倍数
ll LCM(ll a, ll b){
    return a*b/GCD(a, b);
}


int main(void){

    ll a, b, ab, ans = 0;
    vector<ll> divisor;
    bool flag = false;

    cin >> a >> b;

    ab = GCD(a, b);

    for(int i = 2;i < sqrt(GCD(a, b))+1;i++){
        if(ab % i == 0){
            ans++;
            while(ab % i == 0){
                ab /= i;
            }
        }
    }
    if(ab != 1){
        ans++;
    }

    cout << ans+1 << endl;


    return 0;
}

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

int main() {
	vector<int> v(3);
	cin >> v[0] >> v[1] >> v[2];
	sort(v.begin(), v.end());
	cout << 10 * v[2] + v[1] + v[0] << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define taskname "A"
#define pb push_back
#define mp make_pair
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
const int maxn = 5e5 + 5;
const int logn = log2(maxn) + 1;
const int mod = 1e9 + 7;

string s;
int n;
int kmp[maxn] , rkmp[maxn];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if(fopen(taskname".INP", "r")) {
        freopen(taskname".INP", "r", stdin);
        freopen(taskname".OUT", "w", stdout);
    }
    cin >> s;
    n = s.size();
    if(*min_element(s.begin(),s.end()) == *max_element(s.begin(),s.end()))return cout << n << "\n1" , 0;
    int j = 0;
    s = " " + s;
    for(int i = 2 ; i <= n ; ++i){
        while(j > 0 && s[j + 1] != s[i])j = kmp[j];
        if(s[j + 1] == s[i])++j;
        kmp[i] = j;
    }
    rkmp[n] = n + 1;
    j = n + 1;
    for(int i = n - 1 ; i >= 1 ; --i){
        while(j < n + 1 && s[j - 1] != s[i]){
//            cout << i << " " << j << endl;
            j = rkmp[j];
        }
        if(s[j - 1] == s[i])--j;
        rkmp[i] = j;
//        cout << " " << i << " " << rkmp[i] << endl;
    }
//    return 0;
    auto Check = [&](int kmp[] , int pos , bool type){
        return kmp[pos] != 0 && kmp[pos] != n + 1 && (type == 0 ? pos : n + 1 - pos) % abs(pos - kmp[pos]) == 0;
    };
    if(Check(kmp,n,0) == 0)return cout << "1\n1" , 0;
    int res = 0;
    for(int i = 1 ; i <= n - 1; ++i){
        res += (!Check(kmp,i,0) && !Check(rkmp,i+1,1));
    }
    cout << "2\n" << res;
}


Measured memory_bytes: 4788
n = int(input())
s = input()

add_left, cash = 0, 0
for p in s:
    if cash == 0 and p == ")":
        add_left += 1
    elif p == "(":
        cash += 1
    else:
        cash -= 1

add_right, cash = 0, 0
for p in s[::-1]:
    if cash == 0 and p == "(":
        add_right += 1
    elif p == ")":
        cash += 1
    else:
        cash -= 1

print(add_left * "(" + s + add_right * ")")


Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
int main(){
  char a[11],b[11],c[11];
  scanf("%s%*c%s%*c%s",a,b,c);
  if(a[strlen(a)-1]==b[0] && b[strlen(b)-1]==c[0])
    puts("YES");
  else
    puts("NO");
  return 0;
}


Measured memory_bytes: 1660
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


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

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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

















int main(){
    ll n, k, c;
    string s;
    cin >> n >> k >> c >> s;
    vector<ll> L(n, -1), R(n, -1);
    ll cnt = 0;
    REP(i, n){
        if(s[i] == 'o'){
            L[cnt++] = i;
            i += c;
        }
    }
    if(cnt > k){
        return 0;
    }
    for(ll i = n - 1; i >= 0; i--){
        if(s[i] == 'o'){
            R[--cnt] = i;
            i -= c;
        }
    }
    REP(i, n){
        if(L[i] != -1 && L[i] == R[i]){
            cout << L[i] + 1 << endl;
        }
    }
}

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

int main(){
    int n; cin >> n;
    int a[n]; int now=1;
    rep(i,n) cin >> a[i];
    rep(i,n) if(a[i]==now) now++;
    if(now==1) cout << -1 << endl;
    else cout << n-now+1 << endl;
return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		String[] strArry = bf.readLine().split(" ");
		String[] map = {"Even","Odd"};
		int total = Integer.parseInt(strArry[0]) * Integer.parseInt(strArry[1]);
		System.out.println(map[(int)(total % 2)]);
	}
}


Measured memory_bytes: 22484
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  list<int> ls;
  rep(i,N) {
    int b;
    cin >> b;
    ls.push_back(b);
  }
  vi cmd;
  while(sz(ls)>0) {
    int i=0;
    int k=-1;
    for(auto c:ls) {
      i++;
      if(c==i) {
        k=c;
      }
    }
    if(k==-1) {
      cout << -1 << endl;
      return 0;
    }
    cmd.push_back(k);
    ls.erase(next(ls.begin(),k-1),next(ls.begin(),k));
  }
  reverse(rng(cmd));
  rep(i,sz(cmd)) {
    cout << cmd[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

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


Measured memory_bytes: 580
def gcd(a, b):
    if a < b:
        return gcd(b, a)
    while b > 0:
        a, b = b, a % b
    return a

n = int(input())
a_list = list(map(int, input().split()))

checker = [0] * (10 ** 6 + 1)
x = a_list[0]
for a in a_list:
    x = gcd(x, a)
    checker[a] += 1

if all(sum(checker[d::d]) <= 1 for d in range(2, 10 ** 6 + 1)):
    print("pairwise coprime")
elif x == 1:
    print("setwise coprime")
else:
    print("not coprime")
    




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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll; 
typedef std::pair<ll, ll> PLL;

signed main() {
    ll K,A,B;
    cin>>K>>A>>B;
    ll ans=1;

    ans += min(K, A-1);
    K -= min(K,A-1);

    // 0円 ans個
    if (B-A > 2) {
        // なるべく換金
        ll t = K/2;
        ans += t*(B-A);
        K -= 2*t;
    } else{
        // 単純に増やす
        ans += K;
        K = 0;
    }
    
    if (K>0) {
        ans++;
        K--;
    }

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


Measured memory_bytes: 256
N, M, C = map(int, input().split())
B = list(map(int, list(input().split())))
A = []
for i in range(N):
    A.append(list(map(int, list(input().split()))))

counter = 0
for i in range(N):
    recog = 0
    for j in range(M):
        recog += A[i][j]*B[j]
    recog += C
    if recog > 0:
        counter += 1
print(counter)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  vector<int> vecX(N);
  for(int k=0; k<N; k++){
    vecX.at(k) = vec.at(k);
  }
  sort(vec.begin(), vec.end());
  int max_num = vec.at(N-1);
  int second_num = 0;
  if(vec.at(N-1) == vec.at(N-2)){
    second_num = max_num;
  }
  else{
    for(int l=N-1; l>=0; l--){
      if(vec.at(l) != max_num){
        second_num = vec.at(l);
        break;
      }
    }
  }

  for(int j=0; j<N; j++){
    if(vecX.at(j) == max_num){
      cout << second_num << endl;
    }
    else{
      cout << max_num << endl;
    }
  }
}

Measured memory_bytes: 3200
integer(16) N
character(2*10**5) S
integer(16) kcnt,scnt,i
integer ans
read*,N,S
kcnt=0
scnt=0
do i=1,N
  if(S(i:i)==".")scnt=scnt+1
end do
ans=min(scnt,N-scnt)
do i=1,N
  if(S(i:i)=="#")kcnt=kcnt+1
  if(S(i:i)==".")scnt=scnt-1
  if(S(i:i)/=S(i+1:i+1))then
    ans=min(ans,scnt+kcnt)
  endif
end do
print"(I0)",ans
end

Measured memory_bytes: 1084
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>

#define ll long long
#define vl vector<ll>
#define vvl vector< vector<ll> >
#define vb vector<bool>
#define vbb vector< vector<bool> >
#define vs vector<string>
#define vc vector<char>
#define vvc vector< vector<char> >

#define all(a) (a).begin(),(a).end()
using namespace std;

int main(){
	string s; cin >> s;
	ll ngo = 0;
	for (int i = 0; i < s.size(); ++i) ngo += s[i] - '0';
	ll n = 0;
	for (int i = 0; i < s.size(); ++i){
		n += pow(10, i)*(s[s.size() - 1 - i] - '0');
	}
	if (n % ngo == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MOD 1000000007
using namespace std;

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

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

    vector<int> A(N);
    vector<int> B(N - 1);
    rep(i, N - 1) {
        cin >> B[i];
    }

    rep(i, N - 1) {
        if(i == 0) {
            A[0] = B[0];
        } else {
            A[i] = min(A[i], B[i]);
        }
        A[i + 1] = B[i];
    }

    int ans = 0;
    rep(i, N) {
        ans += A[i];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
# Problem C - City Savers

# input
N = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))

# initialization
max_monster = 0

# count
for i in range(N):
    b = b_list[i]
    if a_list[i]<=b:
        max_monster += a_list[i]
        b_list[i] -= a_list[i]
        a_list[i] = 0
    else:
        max_monster += b
        b_list[i] = 0

    b = b_list[i]
    if a_list[i+1]<=b:
        max_monster += a_list[i+1]
        a_list[i+1] = 0
    else:
        max_monster += b
        a_list[i+1] -= b_list[i]

# output
print(max_monster)


Measured memory_bytes: 82148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 0x3f3f3f3f;
typedef vector<ll> vll;
typedef pair<ll, ll> Pll;

ll N;

int main() {
    int N;
    cin >> N;
    if (N / 1000 == N % 1000 / 100 && N % 1000 / 100 == N % 100 / 10 || N % 1000 / 100 == N % 100 / 10 && N % 100 / 10 == N % 10) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
X, N = map(int, input().split())
List = list(map(int, input().split()))
if not X in List:
  ans = X
else:
  n = 1
  while True:
    if not (X - n) in List:         
      ans = X - n
      break
    elif not (X + n) in List:
      ans = X + n
      break
    else:
      n +=1
print(ans)

Measured memory_bytes: 9128
#include<bits/stdc++.h>
//#define ll long long int32_t 
//#define int long long int
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
using namespace std;
const double PI = atan(1.0)*4;
const int64_t INF=20000000000003;
const int32_t LOG=21;
const int MOD=MOD1;
int a[100005],b[100005];
int32_t main()
{ 
	  getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      {
            int n1,n2,m;
            cin>>n1>>n2>>m;
            rep(i,0,n1)cin>>a[i];
            rep(i,0,n2)cin>>b[i];
            int ans=1000005;
            rep(i,0,m)
            {
            	int x,y,c;
            	cin>>x>>y>>c;
                ans=min(ans,a[x-1]+b[y-1]-c);
            }
            sort(a,a+n1),sort(b,b+n2);
            ans=min(ans,a[0]+b[0]);
            cout<<ans<<endl;
      }
      return 0;     
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
	int a[4];
	int count=0;
  for(int i=0;i<4;i++){
  	cin >> a[i];
  }
  for(int i=0;i<4;i++){
    if(a[i]==1 || a[i]==9 || a[i]==7 || a[i]==4){
    	  if(i==0)count++;
    	  else if(a[i]!=a[i-1])count++;
    }
  }
  if(count==4)
    cout << "YES" ;
    else cout << "NO";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,j,k;
  string s,t;
  cin>>n>>s;
  vector<int> dp(n);
  for(j=1;j<n;j++){
    t=s.substr(j-dp[j-1],dp[j-1]+1);
    for(k=0;k<j-2*dp[j-1];k++){
      if(s.substr(k,dp[j-1]+1)==t){
        dp[j]=dp[j-1]+1;
        break;
      }
    }
    if(k==j-2*dp[j-1]) dp[j]=dp[j-1];
  }
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 3700
#include <iostream>
using namespace std;
int main(void){
    int N, K, Q;
    cin >> N >> K >> Q;
    int min = K - Q;
    int t[N];
    int i;
    for(i=0;i<N;i++){
        t[i] = min;
    }
    int ans;
    for(i=0;i<Q;i++){
        cin >> ans;
        t[ans-1] += 1;
    }
    for(i=0;i<N;i++){
        if(t[i]>0){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	for (int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for (int i=n-1;i>=1;i--)
	{
		if (a[i]>a[i+1]+1)
		{
			cout<<"No"<<endl;
			return 0;
		}
		if (a[i]==a[i+1]+1)
		{
			a[i]--;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
 }

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define LL long long
using namespace std;
int Ms[100][100], p[100], t[100];
int main(){
    ios::sync_with_stdio(false);
    int n, m; cin>>n>>m;
    for(int i = 1; i <= m; i++){
        int k; cin>>k; Ms[i][0] = k;
        for(int j = 1; j <= k; j++){
            cin>>Ms[i][j];
        }
    }
    for(int i = 1; i <= m; i++) cin>>p[i];
    int all = 1<<n; all--;
    int ans = 0;
    for(int i = 0; i <= all; i++){
        int ti = i;
        for(int j = 1; j <= n; j++){
            t[j] = ti&1; ti >>= 1;
        }
        bool flag = 1;
        for(int j = 1; j <= m; j++){
            int len = Ms[j][0], cnt = 0;
            for(int k = 1; k <= len; k++){
                if(t[Ms[j][k]]) cnt++;
            }
            if(cnt % 2 != p[j]){
                flag = 0;
                break;
            }
        }
        if(flag) ans++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<=n;i++)
#define ln "\n"
using namespace std;

ll knapsnack(ll n,ll W,ll wt[],ll val[])
{
    ll dp[n+1][W+1],i,j;
    f0(i,n+1)
    f0(j,W+1)
    dp[i][j]=0;
    
    
    f1(i,n)
    {
        f1(j,W)
        {
            if(j-wt[i-1]<0)
            dp[i][j]=dp[i-1][j];
            else
            dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
        }
    }
    
    return dp[n][W];
}
int main()
{
    FAST;
    ll n,i,W;
    cin>>n>>W;
    ll wt[n],val[n];
    f0(i,n)
    cin>>wt[i]>>val[i];
    
    cout<<knapsnack(n,W,wt,val);
	return 0;
}


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

using namespace std;

int dp[100001];
int h[100001];

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

    int n,k;
    cin>> n >> k;

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

    int mini = INT_MAX;

    dp[0] = 0;
    dp[1] = abs(h[0]-h[1]);
    mini = INT_MAX;

    for(int i = 2; i<n; i++)
    {
        //dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
        int pom = 0;
        for(int j = 1; j<=k; j++)
        {
            if(i-j>=0)
            {
                pom = dp[i-j]+abs(h[i]-h[i-j]);
                if(pom<mini) mini = pom;
            }
        }

        dp[i] = mini;
        mini = INT_MAX;
    }

    cout<< dp[n-1];


    return 0;
}


Measured memory_bytes: 1024