akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;



int main(void){
    string s;
    cin >> s;
    int c = 0;
    for(int i = 2;i < s.size() - 1;i++){
          if(s[i] == 'C')c++;
    }
    
    if(s[0] == 'A' && c == 1){
          for(int i = 1;i < s.size();i++){
                if(s[i] == 'C')continue;
                if(!('a' <= s[i] && s[i] <= 'z')){
                      cout << "WA" << endl;
                      return 0;
                }
          }
          cout << "AC" << endl;
    }else{
          cout << "WA" << endl;
    }
    
    
}


Measured memory_bytes: 256
import scala.io.StdIn.{readInt,readLine}
import scala.collection.mutable.HashMap

object Main extends App {
  val n = readInt
  val map = new HashMap[String,Int]
  for(i<-1 to n) {
    val s = readLine.split(" ")
    if(s(0)=="insert")
      map(s(1)) = 1
    else
      if(map.contains(s(1))) println("yes") else println("no")
  }

}

Measured memory_bytes: 466788
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Part(vec, b, e) vec.begin() + b, vec.begin() + e
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(vec, s) vec.find(s) != vec.end()
#define Set_union(A, B, res) set_union(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_intersection(A, B, res) set_intersection(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_difference(A, B, res) set_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_symmetric_difference(A, B, res) set_symmetric_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));

class DisjointSet {
public:
    vector<int> rank, p;

    DisjointSet() {}
    DisjointSet(int size) {
        rank.resize(size, 0);
        p.resize(size, 0);
        for (int i = 0; i < size; i++) makeSet(i);
    }

    void makeSet(int x) {
        p[x] = x;
        rank[x] = 0;
    }

    bool same(int x, int y) {
        return findSet(x) == findSet(y);
    }

    void unite(int x, int y) {
        link(findSet(x), findSet(y));
    }

    void link(int x, int y) {
        if (rank[x] > rank[y]) {
            p[y] = x;
        }
        else {
            p[x] = y;
            if (rank[x] == rank[y]) {
                rank[y]++;
            }
        }
    }

    int findSet(int x) {
        if (x != p[x]) {
            p[x] = findSet(p[x]);
        }
        return p[x];
    }
};

int main() {
	int N, M;
	cin >> N >> M;
    DisjointSet DS(N);
    Rep(i, M) {
        int A, B;
        cin >> A >> B;
        A--, B--;
        DS.unite(A, B);
    }
    set<int> C;
    Rep(i, N) {
        C.insert(DS.findSet(DS.p[i]));
    }
    cout << C.size() - 1 << endl;
	return 0;
}

Measured memory_bytes: 7880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int n,m;
int ans[55];
int a,b;
int main(void){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        ans[a]++;
        ans[b]++;
    }
    for(int i=1;i<=n;i++){
        cout<<ans[i]<<endl;
    }
    
}


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

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
 
typedef long long ll;
using namespace std;
 
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  c = (a+b)*c/2;
  printf("%d\n", c);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
 
int main() {
    int h, w; scanf("%d%d", &h, &w);
    vector <string> lines(h);
    vector <int> cols(h, 0), rows(w, 0);
    for(int i=0;i<h;i++)cin >> lines[i];
    for(int col=0;col<h;col++){
        for(int row=0;row<w;row++){
            if(lines[col][row]=='#'){cols[col]=1;rows[row]=1;}        
            }
    }
    for(int col=0;col<h;col++){
        if(cols[col]==1){
            for(int row=0;row<w;row++){
                if(rows[row]==1)printf("%c", lines[col][row]);
            }
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = (n-1); i >= 0; i--)
#define rea(i, a, b) for (int i = (a); i < (b); i++)
#define reab(i, a, b) for (int i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(),(a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const int MOD = 1000000007;
const ll INF = 10000000000000;
/* END OF TEMPLATE */

vvvll dp(41, vvll(411, vll(411, INF)));

int main(){
    dp[0][0][0] = 0;
    ll n, ma, mb;
    cin >> n >> ma >> mb;
    vll a(n), b(n), c(n);
    rep(i, n){
        cin >> a[i] >> b[i] >> c[i];
    }
    rep(i, n){
        rep(ai, 401){
            rep(bj, 401){
                if(dp[i][ai][bj] == INF) continue;
                dp[i+1][ai][bj] = min(dp[i+1][ai][bj], dp[i][ai][bj]);
                dp[i+1][a[i]+ai][b[i]+bj] = min(dp[i+1][a[i]+ai][b[i]+bj], dp[i][ai][bj]+c[i]);
            }
        }
    }
    ll ans = INF;
    ll iup = accumulate(ALL(a), 0LL);
    ll jup = accumulate(ALL(b), 0LL);
    for(ll i = ma, j = mb; i <= iup && j <= jup; i += ma, j += mb){
        ans = min(ans, dp[n][i][j]);
    }
    if(ans == INF) ans = -1;
    cout << ans << endl;
    /*
    rep(i, 10){
        rep(j, 10){
            dump2(i, j);
            dump(dp[i][j]);
        }
    }
    */
}

Measured memory_bytes: 56192
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	a := make([]int, n)
	ans := 0
	c := map[pair]int{}

	for i := 0; i < n; i++ {
		s := scanString()
		for j := 0; j < len(s); j++ {
			if s[j] == '.' {
				a[i], _ = strconv.Atoi(s[:j])
				s = s[j+1:]
				break
			}
			if len(s)-1 == j {
				a[i], _ = strconv.Atoi(s)
				s = "0"
			}
		}
		a[i] *= 1000000000
		t, _ := strconv.Atoi(s + strings.Repeat("0", 9-len(s)))
		a[i] += t
		c2 := 0
		c5 := 0
		for a[i]%2 == 0 && c2 < 20 {
			a[i] /= 2
			c2++
		}
		for a[i]%5 == 0 {
			a[i] /= 5
			c5++
		}
		for j := 0; j <= 20; j++ {
			for k := 0; k <= 20; k++ {
				if j+c2 >= 18 && k+c5 >= 18 {
					ans += c[pair{j, k}]
				}
			}
		}
		c[pair{c2, c5}]++
	}
	fmt.Fprintln(wr, ans)

}

type pair struct{ a, b int }


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

int main(){
	ll n,h;
	cin >> n >> h;
	vector<ll> a(n);
	vector<ll> b(n);
	rep(i,n) cin >> a[i] >> b[i];
	sort(a.rbegin(),a.rend());
	sort(b.rbegin(),b.rend());
	ll count = 0;
	rep(i,n){
		if(h <= 0) break;
		if(a[0] < b[i]){
			h -= b[i];
			count++;
		}
	}
	if(h > 0){
		count += (h + a[0] - 1) / a[0];
	}
	cout << count << endl;
    return 0;
}



Measured memory_bytes: 4796
alpha = str(input())

a_set = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V",
         "W", "X", "Y", "Z"}

if alpha in a_set:
    print("A")
else:
    print("a")

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

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define mkp make_pair
#define F first
#define S second
typedef pair<int,int> pii;
int h,w;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int dp[55][55][4];
vector<string> v;
bool check(int a,int b){
    if(0<=a&&a<h&&0<=b&&b<w) return true;
    return false;
}
int foo(int a,int b,int c){
    if(!check(a,b)) return 0;
    // cout<<a<<" "<<b<<" "<<c<<endl;
    if(dp[a][b][c]>=0) return dp[a][b][c];
    dp[a][b][c]=0;
    int ret=0;
    if(v[a][b]=='G'){
        return dp[a][b][c]=1;
    }
    int cc=(c-1+4)%4;
    int cc2=(c+1)%4;
    int cc3=(c+2)%4;
    if(v[a+dy[cc]][b+dx[cc]]!='#'){
        ret=foo(a+dy[cc],b+dx[cc],cc);
    }
    else if(v[a+dy[c]][b+dx[c]]!='#'){
        ret=foo(a+dy[c],b+dx[c],c);
    }
    else if(v[a+dy[cc2]][b+dx[cc2]]!='#'){
        ret=foo(a+dy[cc2],b+dx[cc2],cc2);
    }
    else if(v[a+dy[cc3]][b+dx[cc3]]!='#'){
        ret=foo(a+dy[cc3],b+dx[cc3],cc3);
    }
    return dp[a][b][c]=ret;
}   

int main(){
    cin>>h>>w;
    v=vector<string>(h+2);
    rep(i,h) cin>>v[i+1];
    v[0]=v[h+1]=string(w+2,'#');
    reep(i,1,h+1){
        v[i]="#"+v[i]+"#";
    }
    h+=2;
    w+=2;
    // rep(i,h) cout<<v[i]<<endl;
    pii pos;
    int vec;
    rep(i,h){
        rep(j,w){
            if(v[i][j]=='<') pos=mkp(i,j),vec=3,v[i][j]='.';
            if(v[i][j]=='>') pos=mkp(i,j),vec=1,v[i][j]='.';
            if(v[i][j]=='^') pos=mkp(i,j),vec=2,v[i][j]='.';
            if(v[i][j]=='v') pos=mkp(i,j),vec=0,v[i][j]='.';
        }
    }
    rep(i,55) rep(j,55) rep(k,4) dp[i][j][k]=-1;
    foo(pos.F,pos.S,vec);
    set<pii> se;
    pii gg;
    rep(i,55){
        rep(j,55){
            if(check(i,j)&&v[i][j]=='G') gg=mkp(i,j);
            rep(k,4){
                if(dp[i][j][k]==1) se.insert(mkp(i,j));
            }
        }
    }
    if(se.find(gg)==se.end()) cout<<-1<<endl;
    else cout<<se.size()<<endl;
}

Measured memory_bytes: 1576
#include<stdio.h>
#include<iostream>
#include<bits/stdc++.h>
#include<math.h>

int main()
{
	long long int X,A;
std::cin>>X>>A;
	if(X>=A)
	{
		std::cout<<"10"<<"\n";
	}
	else if(X<A)
	{
	std::cout<<"0"<<"\n";
	}
	return 0;
}

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

typedef long long int lli;
typedef long int li;

void solve(){
}

int main(){
	
    ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
    
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    
    int ans = 0;
    if(k <= a + b) ans = min(k, a);
    else ans = a - (k - (a + b));

    cout << ans << '\n';
}	

/*
	check for corner cases.
	When using log check for zeros.
	Use queues and stacks if they are helping.           
                            
    (___)           
    . . )____________ 
   _|__/\           |\
  (o_o_) \__________| \
           /|     ||   )     
          < |     ||  
*/



Measured memory_bytes: 3616
include Math

N = gets.to_i
town = N.times.map(&:to_i)
per = town.permutation.to_a
x, y = N.times.map{gets.split.map(&:to_i)}.transpose
sum = 0

per.each do |v|
  for i in 0..N-2 do
    dx = x[v[i]] - x[v[i+1]]
    dy = y[v[i]] - y[v[i+1]]
    sum += sqrt(dx**2 + dy**2)
  end
end

puts sprintf("%.10f", (sum / per.size))

Measured memory_bytes: 8188
n = int(input())
A = [int(i) for i in input().split()]
S = [0]*(n+1)
num = {}
for i in range(n):
    S[i+1] = S[i] + A[i]
for i in S:
    s = str(i)
    num[s] = 1 if s not in num.keys() else num[s]+1
out = [i*(i-1)//2 for i in num.values() if i > 1]
print(sum(out))

Measured memory_bytes: 52544
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL A, B;
	in >> A >> B;

	LL C = A + B;
	if (C % 2 == 0) out << C / 2 << std::endl;
	else out << "IMPOSSIBLE" << std::endl;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
safe_sunuke_set = set()

for number_of_candies in range(k):
    d = int(input())
    sunuke_list = map(int, input().split())
    for sunuke in sunuke_list:
        safe_sunuke_set.add(sunuke)

print(n - len(safe_sunuke_set))
        





Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n = 5, v[n];
    fore(i,0,n) cin >> v[i];
    sort(v, v+n);
    int mn = 1e9;
    do {
        int cur = 0;
        fore(i,0,n) {
            cur = (cur+9)/10 * 10;
            cur += v[i];
        }
        mn = min(mn, cur);
    } while (next_permutation(v, v+n));
    cout << mn << endl;
}


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

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;

using namespace std;

int A[100005];

int main()
{
	int N, K;
	cin >> N >> K;
	int minI = -1;
	REP(i, N)
	{
		cin >> A[i];
		if (A[i] == 1)minI = i;
	}
	int ans = 0;
	int i = 0;
	while (i < N - 1)
	{
		ans++;
		i += (K - 1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
/*

  _|_|                              _|  _|    _|
_|    _|  _|  _|_|  _|_|_|_|        _|  _|  _|
_|    _|  _|_|          _|          _|  _|_|
_|    _|  _|          _|      _|    _|  _|  _|
  _|_|    _|        _|_|_|_|    _|_|    _|    _|

*/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
//#define ls (rt<<1)
//#define rs (rt<<1|1)
#define vi vector<int>
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a),i##end=(b);i<=i##end;i++)
#define fi first
#define se second
typedef long long ll;
using namespace std;
int ans[1005][1005];
int main(){
    ios::sync_with_stdio(0);
    int k;
    cin>>k;
    int mx=500,need=k-mx;
    if(k<=mx){
        cout<<k<<endl;
        rep(i,1,k){
            rep(j,1,k)cout<<i<<' ';
            cout<<endl;
        }
        return 0;
    }
   /* int sz;
    if(k&1){
        sz=k/2+1;
        rep(i,1,sz)rep(j,1,sz)ans[i][j]=k;
    }
    else{
        sz=k/2;
        rep(i,1,sz)rep(j,1,sz)ans[i][j]=(j&1)?k:(k-1);
    }
    int cnt=0;
    for(int i=sz;i>1;i--){//枚举行
        int bk1=++cnt,bk2=++cnt,s1=bk1,s2=bk2;
        for(int x=i,y=1;x<=sz&&y<=sz;x++,y++)ans[x][y]=s1,swap(s1,s2);
        s1=bk2,s2=bk1;
        for(int x=1,y=sz-i+2;x<=sz&&y<=sz;x++,y++)ans[x][y]=s1,swap(s1,s2);
    }
    rep(i,1,sz){
        rep(j,1,sz)cout<<ans[i][j]<<' ';
        cout<<endl;
    }*/
   int cnt=0;
    cout<<"500"<<endl;
   rep(i,1,need){
        cnt++;
        int nx=i;
        rep(ny,1,mx){
            ans[nx][ny]=(ny&1)?cnt:(cnt+1);
            nx++;if(nx>mx)nx=1;
        }
        cnt++;
    }
    rep(i,need+1,mx){
        cnt++;
        int nx=i;
        rep(ny,1,mx){
            ans[nx][ny]=cnt;
            nx++;if(nx>mx)nx=1;
        }
   }
    rep(i,1,mx){rep(j,1,mx)cout<<ans[i][j]<<' ';cout<<endl;}
    return 0;
}

Measured memory_bytes: 5616
s=input()


#\\///\_/\/\\\\/_/\\///__\\\_\\/_\/_/\
    

stack=[]
i=0
result=0
#みずたまりは、[左側の位置と、数量を表す]
mizutamari=[[-1,0]]
for item in s:
    #print(stack,mizutamari)
    if item=="\\":
        stack.append(i)
    elif item=="/":
        if len(stack)>0:
            temp=stack.pop()
            result+=i-temp
            left=mizutamari.pop()
            if left[0]>temp:
                vol=i-temp
                while 1:
                    vol=left[1]+vol
                    mizutamari.append([temp,vol])
                    if len(mizutamari)<=2:
                        break
                    bk=mizutamari.pop()
                    bkbk=mizutamari.pop()
                    if bkbk<bk:
                        mizutamari.append(bkbk)
                        mizutamari.append(bk)
                        break
                    else:
                        left=bkbk




                
            else:
                #print(left[0],"<",temp,":","naze",left,temp)
                mizutamari.append(left)
                mizutamari.append([temp,i-temp])
                #print(mizutamari)


    i+=1
print(result)
s=""
for item in mizutamari[1:]:
    s+=str(item[1])+" "

if result==0:
    print(0)
else:
    print(len(mizutamari)-1,s[:-1])


Measured memory_bytes: 6128
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep4(i, a, b, c) for (int i = int(a), i##__b = int(b), i##__c = int(c); i < i##__b; i += i##__c)
#define rep1(n) rep4(i, 0, n, 1)
#define rep2(i, n) rep4(i, 0, n, 1)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define REP(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep3(i, a, b) for (int i = int(b) - 1, i##__a = int(a); i >= i##__a; i--)
#define rrep1(n) rrep3(i, 0, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep4(i, a, b, c) for (int i = int(a + (b - a - 1) / c * c), i##__a = int(a), i##__c = int(c); i >= i##__a; i -= i##__c)
#define RREP(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define FOR(i, x) for (auto &i : x)
#define ALL(v) (v.begin()), (v.end())
#define pb(x) emplace_back(x)
#define mp(x, y) make_pair(x, y)
#define mt make_tuple
#define endl '\n'
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using vstring = vector<string>;
template <class T> using vv = vector<vector<T>>;
template <class T> using pq = priority_queue<T>;
template <class T> using rpq = priority_queue<T, vector<T>, greater<T>>;
#define vvint(A, H, W) vvint A(H, vint(W))
const int MOD = 1e9 + 7;
const int INF = 1e9 + 9;
const ll LINF = 1e18;
template <class T> bool chmax(T &a, const T &b) {if (a < b) {a = b;return 1;}return 0;}
template <class T> bool chmin(T &a, const T &b) {if (b < a) {a = b;return 1;}return 0;}
#define print(x){cout<<x<<endl;}
// clang-format on

int main() {
    int v, e, r;
    cin >> v >> e >> r;
    vv<pii> edge_to_d(v);
    REP(e) {
        int s, t, d;
        cin >> s >> t >> d;
        edge_to_d[s].pb(mp(t, d));
    }
    vll ans(v, LINF);
    ans[r] = 0;
    // q : (暫定最短距離, 最短であると確定している頂点に接する頂点)の集まり
    // 取り出したものは最短確定
    // 今の頂点に接する頂点のうち、暫定最短距離を更新できるなら候補として(暫定最短距離, その頂点)を追加
    //     (更新しないほうが良ければ、取り出すだけで終了)
    rpq<pll> q;
    q.push(mp(0, r));
    while (!q.empty()) {
        ll nowd, now;
        tie(nowd, now) = q.top();
        q.pop();
        FOR(to, edge_to_d[now]) {
            int t, d;
            tie(t, d) = to;
            if (chmin(ans[t], nowd + d)) {
                q.push(mp(nowd + d, t));
            }
        }
    }
    REP(v) {
        if (ans[i] == LINF) {
            print("INF");
        } else {
            print(ans[i]);
        }
    }
}



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

int main(){
  int N; cin >> N;
  vector<vector<long long>> abc(N, vector<long long>(3));
  for (int i=0; i<N; i++){
    for (int j=0; j<3; j++) cin >> abc[i][j];
  }
  vector<vector<long long>> dp(N, vector<long long>(3,0));
  dp[0][0] = abc[0][0];
  dp[0][1] = abc[0][1];
  dp[0][2] = abc[0][2];
  for (int i=1; i<N; i++){
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + abc[i][0];
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + abc[i][1];
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + abc[i][2];
  }
  cout << max(dp[N-1][0], max(dp[N-1][1], dp[N-1][2])) << endl;
}


Measured memory_bytes: 11136
from sys import stdin

def main():

    input = stdin.readline

    A,B,C,D = map(int,input().split())

    A_turn = (C + B - 1) // B
    C_turn = (A + D - 1) // D

    if A_turn <= C_turn:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

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

fn main() {
    let n: usize = read();
    let h: Vec<i64> = (0..n).map(|_| read()).collect();
    let inf: i64 = 1_i64 << 40;

    let mut dp: Vec<i64> = vec![inf; n];
    dp[0] = 0;
    for i in 0..n {
        if i + 1 < n {
            dp[i + 1] = std::cmp::min(dp[i + 1], dp[i] + (h[i + 1] - h[i]).abs());
        }
        if i + 2 < n {
            dp[i + 2] = std::cmp::min(dp[i + 2], dp[i] + (h[i + 2] - h[i]).abs());
        }
    }
    println!("{}", dp[n-1]);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

typedef pair<int, int> ii;

int n;

string ans, newans;

int main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n;
    cout << "0\n";
    cout.flush();
    cin >> ans;
    if(ans == "Vacant"){
        cout << "0\n";
        cout.flush();
        cin >> ans;
        exit(0);
    }
    int pos = 0;
    for(int i = 17; i >= 0; i--){
        if(pos + (1 << i) < n){
            cout << pos + (1 << i) << "\n";
            cout.flush();
            cin >> newans;
            if(newans == "Vacant"){
                cout << pos + (1 << i) << "\n";
                cout.flush();
                cin >> newans;
                exit(0);
            }
            if(ans == newans)
                pos += (1 << i);
        }
    }
    cout << pos + 1 << "\n";
    cout.flush();
    cin >> newans;
    exit(0);
}


Measured memory_bytes: 852
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int d = in.nextInt();
		int t = in.nextInt();
		int s = in.nextInt();
		if (t * s < d)
			System.out.println("No");
		else
			System.out.println("Yes");
	}
}


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

int main() {
  
  string S;
  cin >> S;
  
  string SA = "", SB = "";
  
  for (int i = 0 ; i < S.size() ; i++){
    if (i % 2 == 0){
      SA += "0";
      SB += "1";
    }
    else{
      SA += "1";
      SB += "0";
    }
  }
  
  int SANum = 0 , SBNum  = 0 ;
  
  for (int i = 0 ; i < S.size() ; i++){
    
    if (S.at(i) != SA.at(i))
      SANum++;
    
    if (S.at(i) != SB.at(i))
      SBNum++; 
  }
  
  
  if (SANum < SBNum){
    cout << SANum << endl;
  }
  else {
    cout << SBNum << endl;
  }
  
}


Measured memory_bytes: 768
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {

            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       




        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var ss = Console.ReadLine();
            var n = false;
            var w = false;
            var e = false;
            var s = false;
           
            for (int i = 0; i < ss.Length; i++)
            {
                if (ss[i] == 'N') n = true;
                if (ss[i] == 'S') s = true;
                if (ss[i] == 'W') w = true;
                if (ss[i] == 'E') e = true;
            }
            if (!s ^ n && !e ^ w) Console.WriteLine("Yes");
            else Console.WriteLine("No");



            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 11092
#include <stdio.h>
int main(){
  int inf=1000001;
  int a,i,n,min=inf,max=-inf;
  long long sum=0;
  
  scanf("%d",&n);
  
  for(i=0; i<n; i++){
    scanf("%d",&a);
    
    if(min>a) min=a;
    if(max<a) max=a;
    sum+=a;
  }
  printf("%d %d %lld\n",min,max,sum);

  
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define VMAX 50
#define EMAX 500
#define DMAX 20
#define TRUE 1
#define FALSE 0
#define NOTUSED 0
#define END -1
#define ROOT -1

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

    cout<<a*b<<endl;
}

Measured memory_bytes: 3572
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

std::string x;
int r[225816][2];

int f(int x){
	if(!x){
		return 0;
	}
	return f(x%__builtin_popcount(x))+1;
}

int main(void){
	int n,m[2]={1,-1},i,j,t[2]={0,0};
	std::cin >> n;
	std::cin >> x;
	for(i=0; i<n; ++i){
		x[i] -= '0';
		m[0] += x[i];
		m[1] += x[i];
	}
	r[n-1][0] = 1%m[0];
	if(m[1]){
		r[n-1][1] = 1%m[1];
	}
	for(i=n-1; i>0; --i){
		for(j=0; j<2; ++j){
			if(m[j]){
				r[i-1][j] = r[i][j]*2;
				r[i-1][j] %= m[j];
			}
		}
	}
	for(i=0; i<n; ++i){
		for(j=0; j<2; ++j){
			if(m[j]){
				t[j] *= 2;
				t[j] += x[i];
				t[j] %= m[j];
			}
		}
	}
	for(i=0; i<n; ++i){
		// std::cout << (t[x[i]]+m[x[i]]+(x[i]?(-r[i][x[i]]):r[i][x[i]]))%m[x[i]] << std::endl;
		// std::cout << m[x[i]] << std::endl;
		if(m[x[i]]){
			std::cout << f((t[x[i]]+m[x[i]]+(x[i]?(-r[i][x[i]]):r[i][x[i]]))%m[x[i]])+1 << std::endl;
		}else{
			std::cout << 0 << std::endl;
		}
	}
	return 0;
}


Measured memory_bytes: 5288
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j) for(int i=0;i<j;i++)
#define max(i,b) (i>b)?i:b
int main(void)
{
	int array[200000];
	int temp[200000];
	int N,tmp,m1,m2;
	scanf("%d",&N);
	rep(i,N){scanf("%d",&array[i]);temp[i]=array[i];}
	sort(temp,temp+N);
	m1=temp[N-1];
	m2=temp[N-2];
	rep(i,N){
		if(array[i]==m1) printf("%d\n",m2);
		else printf("%d\n",m1);
	}
}


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

typedef long long ll;
typedef long double ld;

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

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

int main(){

    set<ll> p;
    ll a;

    rep(i, 3){
        cin >> a;
        p.insert(a);
    }

    cout << p.size() << endl;

    return 0;
}

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

long gcd(long a, long b){
  if(b == 0) return a;
  return gcd(b, a%b);
}

long lcm(long a, long b){
  return a / gcd(a, b) * b;
}

long lcm_of_array(long ans, int index, int array_size, long T[]){
  if(index == array_size) return ans;
  return lcm_of_array(lcm(ans, T[index]), index + 1, array_size, T);
}

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

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

  cout << lcm_of_array(1, 0, n, T) << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(x) for x in input().split()]

cnt = 0
for i in range(n):
    if a[i] < 0:
        cnt += 1
        a[i] *= -1

a.sort()

if cnt % 2 != 0:
    a[0] *= -1

print(sum(a))

Measured memory_bytes: 20060
#include "bits/stdc++.h"

using namespace std;

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

	string str;
	cin >> str;
	int i;
	for (i = 0; i < 4; i++)
		cout << str[i];
	cout << ' ';
	for (; i < 12; i++)
		cout << str[i];
	cout << endl;


	return 0;

}

Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))
    x = 0
    s = 0
    r = 0
    res = 0
    for l in range(N):
        while N > r:
            if s & A[r] != 0: break
            s += A[r]
            r += 1

        s -= A[l]
        res += r - l

    print(res)
if __name__ == '__main__':
    main()


Measured memory_bytes: 77772
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  int n; cin >> n;
  vector<vector<double>> dp(n+1, vector<double>(n+2, 0.0));
  vector<double> p(n);
  rep(i, n) cin >> p[i];

  dp[1][1] = p[0];
  dp[1][0] = 1 - p[0];

  for (int i = 1; i < n; i++) {
    for (int j = 0; j <= n; j++) {
      dp[i+1][j+1] += dp[i][j] * p[i];
      dp[i+1][j] += dp[i][j] * (1 - p[i]);
    }
  }

  double ans = 0.0;
  for (int i = (n+1) / 2; i <= n; i++) {
    ans += dp[n][i];
  }

  printf("%.10f\n", ans);

  return 0;
}


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

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

string to_string(string s) {
    return s;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

#ifndef ONLINE_JUDGE
#define trace(...) __debug(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __debug(const char* name , Arg1&& arg1) {
    cerr << name << " : " << to_string(arg1) << endl;
}
template <typename Arg1 , typename... Args>
void __debug(const char* names , Arg1&& arg1 , Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names , comma - names) << " : " << to_string(arg1) << " | ";
    __debug(comma+1, args...);
}
#else
#define trace(...) 42
#endif

#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define double long double
#define endl '\n'

int calc(int len) {
    int e = 1;
    for(int i = 0; i < len; i++) {
        e *= 26;
    }
    return e;
}

signed main() {
    fio;
    int n; cin >> n;
    int len = 1 , cur = 0 , prev = 0;
    while(cur + calc(len) < n) {
        cur += calc(len);
        prev = cur;
        len++;
    }
//    cout << len << endl;
    for(int i = 1; i < len; i++) n -= calc(i);
    
    string res = "";
    for(int i = 0; i < len; i++) {
        char c = 'a';
        int times = 1;
        while(c < 'z' and times * calc(len - i - 1) < n) {
            c++;
            times++;
        }
        n -= (times - 1) * calc(len - i - 1);
        res += c;
    }
    
    cout << res << endl;
    
    return 0;
}




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

#define int long long

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

int N, L;
int zero[100001] = {}, one[100001] = {}, h[100001] = {};

signed main() {
    cin >> N >> L;
    int max = 1;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        int cur = 1;
        for (int j = 0; j < s.length(); j++) {
            h[cur] = L - j;
            if (s[j] == '0') {
                if (zero[cur] == 0) {
                    max++;
                    zero[cur] = max;
                }
                cur = zero[cur];
            } else {
                if (one[cur] == 0) {
                    max++;
                    one[cur] = max;
                }
                cur = one[cur];
            }
        }
    }
    int ans = 0;
    for (int i = 1; i <= 100000; i++) {
        if ((zero[i] == 0 && one[i] != 0) || (zero[i] != 0 && one[i] == 0)) {
            ans ^= h[i] & - h[i];
        }
    }
    if (ans == 0) {
        cout << "Bob" << endl;
    } else {
        cout << "Alice" << endl;
    }
    return 0;
}


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

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

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


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

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		int N=sc.nextInt();
		int[] A=new int[N];
		HashMap<Integer,Integer> map=new HashMap<>();
		long cur=0;
		for (int i=0;i<N;++i) {
			A[i]=sc.nextInt();
			map.merge(A[i], 1, Integer::sum);
			cur+=A[i];
		}
		Arrays.sort(A);
		int Q=sc.nextInt();
		PrintWriter pw=new PrintWriter(System.out);
		for (int q=0;q<Q;++q) {
			int B=sc.nextInt();
			int C=sc.nextInt();
			if (!map.containsKey(B)) {
				pw.println(cur);
				continue;
			}
			cur+=(long)C*map.get(B)-(long)B*map.get(B);
			map.merge(C, map.get(B), Integer::sum);
			map.put(B, 0);
			pw.println(cur);
		}
		pw.flush();
	}

	void tr(Object...o) {System.out.println(Arrays.deepToString(o));}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
        	ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 57508
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
//#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

string s;
int n,k;
ll dp[4][305][2];

ll go(int on,int id,int nz)
{
	if(nz>k)return 0;
	if(id==n)
	{
		if(nz==k)return 1;
		return 0;
	}
	if(dp[nz][id][on]!=-1)return dp[nz][id][on];
	int st=0;
	int en=9;
	if(on==1)en=s[id]-'0';
	ll &r=dp[nz][id][on];
	r=0;
	rep(i,st,en)
	{
		int on2=on;
		if(i<en)on2=0;
		r+=go(on2,id+1,nz+(i>0));
	}
	return r;
}

int main()
{ios_base::sync_with_stdio(false);
cin>>s;
cin>>k;
n=s.length();
rep(i,0,3)rep(j,0,304)rep(k,0,1)dp[i][j][k]=-1;
ol(go(1,0,0));
return 0;
}



Measured memory_bytes: 256
import itertools
N,M=map(int,input().split())
L=[list(map(int,input().split())) for i in range(M)]
P=list(map(int,input().split()))
ans=0
for item in itertools.product(range(2),repeat=N):
  if all(sum(item[x-1] for x in L[i][1:])%2==P[i] for i in range(M)):
    ans+=1
print(ans)

Measured memory_bytes: 42568
str = input()
length = len(str)
ans = [""] * length
for x in range(length):
    if str[length - (x + 1)] == "P":ans[length - (x + 1)] += "P"
    elif str[length - (x + 1)] == "D":ans[length - (x + 1)] += "D"
    elif str[length - (x + 1)] == "?":
        if x == 0 or x == length - 1: ans[length - (x + 1)] = "D"
        elif ans[length - x] == "P": ans[length - (x + 1)] = "D"
        elif ans[length - x] == "D" and str[length - (x + 2)] == "P": ans[length - (x + 1)] = "D"
        elif ans[length - x] == "D" and str[length - (x + 2)] == "D": ans[length - (x + 1)] = "P"
        elif ans[length - x] == "D" and str[length - (x + 2)] == "?": ans[length - (x + 1)] = "P"
print(''.join(ans))

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug if(true)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	int n,m,i,j;
	scanf("%d %d",&n,&m);
	int tot = 0;
	int a[101];

	for(i=0;i<n;i++){scanf("%d",&a[i]); tot += a[i];}
	int minim = tot / (4*m);
	if(tot % (4*m) == 0){
		minim--;
	}
	int ans = 0;
	for(i=0;i<n;i++){
		if(a[i] > minim){
			ans++;
		}
	}
	if(ans >= m){printf("Yes\n");}
	else{
		printf("No\n");
	}
	return 0;
};

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

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)

typedef long long ll;

int main()
{
    string S;
    cin>>S;
    int a[100];
    int n = S.length();
    FOR(i,0,n) a[i]=S[i]-'0';
    
    int ans = 999;
    FOR(i,0,n-2){
        int x = a[i]*100+a[i+1]*10+a[i+2];
        if(abs(x - 753) <= ans) ans = abs(x-753);
    }
    cout<<ans<<endl;
}



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

N = int(input())
ans = 0
p_ = 0
f = False
for i, p in enumerate([int(x) for x in input().split()], start=1):
  if i == p:
    if f:
      ans += 1
      f = False
    else:
      f = True
  else:
    if f:
      ans += 1
      f = False
else:
  if f:
    ans += 1
print(ans)

Measured memory_bytes: 14260
#include <stdio.h>

int main(void)
{

    long l_inputBallNum;
    long l_blueBallNum;
    long l_redBallNum;
    long l_sumBall;
    long l_ballSetCount;
    long l_remainBallNum;
    long l_output;

    scanf("%ld%ld%ld", &l_inputBallNum, &l_blueBallNum, &l_redBallNum);

    l_sumBall = l_blueBallNum + l_redBallNum;
    l_ballSetCount = l_inputBallNum / l_sumBall;
    l_remainBallNum = l_inputBallNum % l_sumBall;

    if (l_remainBallNum > l_blueBallNum)
    {
        l_output = (l_ballSetCount + 1) * l_blueBallNum;
    }
    else
    {
        l_output = l_ballSetCount * l_blueBallNum + l_remainBallNum;
    }

    printf("%ld", l_output);

}

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

N=int(input())
A=list(map(int,input().split()))

S=sum(A)
ANS=0
mod=10**9+7
for i in range(N):
    ANS=ANS+(S-A[i])*A[i]
    ANS%=mod

print(ANS*pow(2,-1,mod)%mod)


Measured memory_bytes: 31464
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {

    static int result = 0;
    static long n = 0;
    
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		n = sc.nextLong();
		
		// 計算
		count(0, false, false, false);
		
		// 出力
		System.out.println(result);
	}
	
	static void count(long now, boolean bool3, boolean bool5, boolean bool7){
	    if(now > n) return;
	    if(bool3 && bool5 && bool7) result++;
	    long n3 = now * 10 + 3;
	    long n5 = now * 10 + 5;
	    long n7 = now * 10 + 7;
	    count(n3, true, bool5, bool7);
	    count(n5, bool3, true, bool7);
	    count(n7, bool3, bool5, true);
	}
}

Measured memory_bytes: 23636
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//define
#define inp(X) cin>>X;
#define inp_long(X) long long X; cin>>X;
#define inp_arr(A,N) long long A[N]; for(int i=0;i<N;i++) {cin>>A[i];}
#define sz(A) A.size()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define endl '\n'
#define vect(A) vector<long long> A;
#define inp_vect(A,N); for(int i=0;i<N;i++){long long q; cin>>q; A.push_back(q);}
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define forde(i,a,b) for(long long i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);

ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2) % MOD;
    p = (p * p) % MOD;

    return (y%2 == 0)? p : (x * p) % MOD;
}
ll modInverse(ll a)
{
   return power(a,MOD-2);
}
int main()
{
	fio;
	string s,t;
	cin>>s>>t;
	int ans=0;
	forin(i,0,2)
	{
		if(s[i]==t[i])
		{
			ans++;
		}
	}
	cout<<ans<<endl;
}



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

int main(void) {
  string str;
  int n;
  cin >> str;
  cin >> n;

  for (int i = 0; i < n; i++) {
    string command;
    int begin, end;
    cin >> command >> begin >> end;
    
    if(command == "replace"){
      string s;
      cin >> s;
      str.replace(begin, end - begin + 1, s);
    }
    else if(command == "reverse") {
      reverse(str.begin() + begin, str.begin() + end + 1) ;
    }
    else if(command == "print") {
      cout << str.substr(begin, end - begin + 1)  << endl;
    }
  }
    
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

// O(√n) time
vector<long long> divisor(long long n) {
    vector<long long> res;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i * i != n)
                res.push_back(n / i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

void _main() {
    int N, M;
    cin >> N >> M;
    int ans = 0;
    for (int d : divisor(M)) {
        int rem = M / d;
        if (rem >= N) {
            ans = max(ans, d);
        }
    }
    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc165/tasks/abc165_e

N, M = gets.split.map(&:to_i)

# - Nが奇数の場合
#   1, 3, ... , 2*M+1 の距離となるペアを生成
#   反対側から数えた距離との組み合わせは常に奇数+偶数になるので、
#   全て混ぜても重複しない
# - Nが偶数の場合
#   1, 3, ... , N/2-2, N/2+1, ... , 2*M
#   または
#   1, 3, ... , N/2-1, N/2+2, ... , 2*M
#   の距離となるペアを生成
#   距離が奇数+奇数または偶数+偶数の組み合わせで生成されるので
#   同じ奇数+奇数が発生する前に片方の位置を1ずらして偶数+偶数に変える

a = N / 2
b = N / 2 + 1
M.times do
  puts "#{a} #{b}"
  a -= 1
  b += 1
  d = b - a
  a -= 1 if N.even? && d.odd? && d >= N - d
end


Measured memory_bytes: 14324
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,n) for(int i = (a); i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define debug_v(v,N) for(int i=0;i<N;i++) { cout << v[i] << " "; } cout << endl;
#define debug_vv(v,H,W) for(int i=0;i<H;i++) { for(int j=0;j<W;j++) { cout << v[i][j] << " "; } cout << endl; }

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int N; cin >> N;
	ll K; cin >> K;
	int Q; cin >> Q;
	vi A(Q);
	rep(i,Q) cin >> A[i];
	vector<ll> res(N, K - Q);
	rep(i,Q) {
		res[--A[i]]++;
	}
	rep(i,N) {
		cout << (res[i] > 0 ? "Yes" : "No") << endl;
	}
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 1792
n = gets.to_i
heights = gets.split.map(&:to_i)

max_height = heights[0]
result = 'Yes'

(n - 1).times do |i|
  next_stair_height = heights[i + 1]

  if max_height <= next_stair_height || max_height - 1 <= next_stair_height
    max_height = [max_height, next_stair_height].max
    result = 'Yes'
  else
    result = 'No'
    break
  end
end

puts result

Measured memory_bytes: 11140