akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <array>
#include <deque>
#include <bitset>
typedef long long ll;
using namespace std;
#define trace(x) cerr << #x << " is " << x << endl;
 
int main() {
    int n, w;
    scanf("%d", &n);
    scanf("%d", &w);
    int weight[n + 1];
    int value[n + 1];
    for (int i = 1; i <= n; i++) {
        scanf("%d", &weight[i]);
        scanf("%d", &value[i]);
    }
    vector<ll> dp(w + 1, 0);
    for (int i = 1; i <= n; i++) {
        for (int j = w; j >= 0; j--) {
            if (j >= weight[i]) {
                dp[j] = max(dp[j - weight[i]] + value[i], dp[j]);
            }
        }
    }
    cout << dp[w] <<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <fstream>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>

using namespace std;

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

#define F first
#define S second
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()

const int N = 2e6;
const int INF = 1e9 + 123;
const double EPS = 1e-9;

string s, t;
vector <int> v1, v2;
map <char, int> mp1, mp2;

int main () {
    ios_base :: sync_with_stdio(0);
    cin >> s >> t;
    for(int i = 0; i < sz(s); ++i) {
        ++mp1[s[i]];
        ++mp2[t[i]];
    }
    for(int i = 0; i < sz(s); ++i) {
        v1.pb(mp1[s[i]]);
        v2.pb(mp2[t[i]]);
    }
    sort(all(v1));
    sort(all(v2));
    if(sz(v1) != sz(v2)) {
        cout << "No\n";
        return 0;
    }
    for(int i = 0; i < sz(v1); ++i) {
        if(v1[i] != v2[i]) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}

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

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

using namespace std;

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

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

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

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

int main(){
	fast_io
	string s; cin>>s;
	int b=0;
	string p="";
	rrep(i,s.size()-1,0){
		if(s[i]=='B') b++;
		else if(b>0) b--;
		else p+=s[i];
	}
	rrep(i,p.size()-1,0){
		cout<<p[i];
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define max(a,b) ((a)<(b)?(b):(a))
#define min(a,b) ((a)<(b)?(a):(b))
#define swap(a,b) a^=b^=a^=b
#define lb(x) ((x)&(-(x)))
#define dalao 1000000007
#define inf 0x3f3f3f3f
#define N 1000010
using namespace std;
typedef long long ll;
int n,sum[N],mi=0x3f3f;
char s[N],t[N];
int main(){
	scanf("%d%s",&n,s+1);
	for(int i=1;i<=n;i++)sum[i]=sum[i-1]+(s[i]=='('?1:-1),mi=min(mi,sum[i]);
	if(mi<0){
		for(int i=n;i;i--)s[i-mi]=s[i];
		for(int i=1;i<=-mi;i++)s[i]='(';
		n-=mi;
		for(int i=1;i<=n;i++)sum[i]=sum[i-1]+(s[i]=='('?1:-1);
	}
	if(sum[n]!=0){
		mi=sum[n];
		while(mi--)s[++n]=')';
	}
	s[n+1]=0;
	printf("%s",s+1);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdlib.h>
#include <algorithm>
#include <utility>
#include <vector>
#define llint long long

using namespace std;

llint n;
vector<pair<llint, llint> > vec;

int main(void)
{
	cin >> n;
	llint a, b;
	for(int i = 0; i < n; i++){
		cin >> a >> b;
		vec.push_back(make_pair(b, a));
	}
	sort(vec.begin(), vec.end());
	
	llint t = 0;
	for(int i = 0; i < vec.size(); i++){
		t += vec[i].second;
		if(t > vec[i].first){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

using namespace std;

int main(){
  int l; cin >> l;
  vector<int> c(l);
  for(auto& a:c) cin >> a;
  vector<int> io(l);
  int now=0,ans=0;
  for(int i=0;i<l;++i) {
    if(c[i]>0) {
      if(find(io.begin(),io.end(),c[i])!=io.end()) {
	ans=i+1;
	break;
      }
      io[now++]=c[i];
    } else {
      if(now==0) {
	ans=i+1;
	break;
      }
      if(io[now-1]!=-c[i]) {
	ans=i+1;
	break;
      }
      io[--now]=0;
    }
  }
  if(ans) cout << ans << endl;
  else cout << "OK" << endl;
  
  return 0;
}



Measured memory_bytes: 3112
def main():
    import numpy as np
    n, k = map(int, input().split())
    aa = np.array(sorted(list(map(int, input().split()))), dtype=np.int64)
    f = np.array(sorted(list(map(int, input().split())),
                        reverse=True), dtype=np.int64)

    a = 0
    b = 10**12+10
    while a+1 < b:
        med = (a+b)//2
        if np.sum(np.maximum(aa-med//f, np.zeros(n, dtype=np.int64))) > k:
            a = med+1
        else:
            b = med
    if a == b:
        print(a)
    else:
        if np.sum(np.maximum(aa-a//f, np.zeros(n, dtype=np.int64))) > k:
            print(b)
        else:
            print(a)


main()


Measured memory_bytes: 37276
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        scanner.close();
        StringBuilder sb = new StringBuilder();

        for (char c : s.toCharArray()) {
            if (c == '0') {
                sb.append(0);
            } else if (c == '1') {
                sb.append("1");
            } else if (c == 'B') {
                if (sb.length() > 0)  {
                    sb.deleteCharAt(sb.length()-1);
                }
            }
        }

        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 35624
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <regex>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include<tuple>

using namespace std;

int main() {
	int N;
	string ans;

	cin >> N;

	int sign = 1;

	while (N) {
		if (N % 2) {
			N -= sign;
			ans = '1' + ans;
		}
		else {
			ans = '0' + ans;
		}

		N /= 2;
		sign = -sign;
	}

	if (ans.length() == 0) cout << 0 << endl;
	else cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
import numpy as np
# sympy as syp(素因数分解とか)
Mod = 1000000007
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1] 
for i in range(2, 10**5 + 1):
    fact.append((fact[-1] * i) % Mod)
    inv.append((-inv[Mod % i] * (Mod // i)) % Mod)
    factinv.append((factinv[-1] * inv[-1]) % Mod)
    
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p
    
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[y] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main():  #startline-------------------------------------------
    x = list(map(int, input().split()))
    print(15-sum(x))
if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 38648
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

using Graph = vector<vector<int>>;

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

	Graph graph(N);
	for (int ii = 0; ii < M; ++ii){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	//初期化
	vector <int> mark(N, -1);
	queue<int> q;
	int initIdx = 0;
	q.push(initIdx);	//最初のキューを追加
	while (!q.empty()) {	//キューが空になるまで探索
		int idx = q.front();
		q.pop();	//キューから値を取り出す
		for (auto nv : graph[idx]){
			if (mark[nv] == -1){
				mark[nv] = idx + 1;
				q.push(nv);
			}
		}
	}

	bool OK = true;
	for (int ii = 1; ii < N; ++ii){
		if (mark[ii] == -1){
			OK = false;
			break;
		}
	}


	if (OK){
		cout << "Yes" << endl;
		for (int ii = 1; ii < N; ++ii){
			cout << mark[ii] << endl;
		}
	} else {
		cout << "No" << endl;		
	}

	return 0;
}


Measured memory_bytes: 10124
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
typedef long long ll;
using namespace std;
int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    int k,n;
    cin >> k >> n;
    vector<int> a(n);
    rep(i,n){
        int in;
        cin >> in;
        a.at(i) = in;
    }
    vector<int> tmp(n);
    rep(i,n - 1){
        tmp.at(i) = a.at(i + 1) - a.at(i);
    }
    tmp.at(n - 1) = (k - a.at(n - 1)) + a.at(0);
    cout << k - *max_element(tmp.begin(),tmp.end()) << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int main(void) {
    int n;
    scanf("%d", &n);
    int v[n];
    double v2[n];
    for(int i = 0; i < n; i++) {
        scanf("%d", &v[i]);
    }
    qsort(v, sizeof(v)/sizeof(int), sizeof(int), asc);
    for(int i = 0; i < n; i++) {
        v2[i] = v[i];
    }
    for(int i = 1; i < n; i++) {
        v2[0] = (v2[0] + v2[i]) / 2;
    }
    printf("%f\n", v2[0]);
    return 0;
}


Measured memory_bytes: 128
from bisect import bisect_right
from random import randint
from copy import deepcopy


def calculate_score(c, L):
    global D, last, S
    rst = 0
    _last = L
    for d in range(1, D + 1):
        down = C[c] * (d - _last[d])
        up = S[d][c] if _last[d] == d else 0
        rst += up - down
    return rst


Z = 26
D = int(input())
C = list(map(int, input().split()))
S = [tuple([0] * Z)] + [tuple(map(int, input().split())) for _ in range(D)]

last = [-1] * Z
ans = 0
T = [0]
for d in range(D):
    maxScore = -float('inf')
    cand = 0
    for i in range(26):
        tmp = last[i]
        last[i] = d
        up = S[d][i]
        down = sum(C[j] * (d - last[j]) for j in range(Z))
        score = up - down
        if maxScore < score:
            cand = i
            maxScore = score
        last[i] = tmp
    last[cand] = d
    T.append(cand)


last = [[0] * (D + 1) for _ in range(Z)]
V = [0] * Z
for d in range(1, D + 1):
    t = T[d]
    for p in range(Z):
        last[p][d] = last[p][d - 1]
    last[t][d] = d
for p in range(Z):
    V[p] = calculate_score(p, last[p])

score = sum(V)
maxScore = score
maxT = deepcopy(T)
# print('Initial Score: ', score)

max_iter = 10 ** 4
for _ in range(max_iter):
    d = randint(1, D)
    q = randint(0, Z - 1)

    p = T[d]
    if p == q:
        continue

    e = bisect_right(last[p], d)
    _lastP = [0] * (D + 1)
    for j in range(d):
        _lastP[j] = last[p][j]
    for j in range(d, e):
        _lastP[j] = _lastP[j - 1]
    for j in range(e, D + 1):
        _lastP[j] = last[p][j]

    old = last[q][d]
    e = bisect_right(last[q], old)
    _lastQ = [0] * (D + 1)
    for j in range(d):
        _lastQ[j] = last[q][j]
    for j in range(d, e):
        _lastQ[j] = d
    for j in range(e, D + 1):
        _lastQ[j] = last[q][j]

    Vp = calculate_score(p, _lastP)
    Vq = calculate_score(q, _lastQ)
    if V[p] + V[q] < Vp + Vq:
        score -= V[p] + V[q]
        score += Vp + Vq
        V[p] = Vp
        V[q] = Vq
        T[d] = q
        last[p] = _lastP
        last[q] = _lastQ
        if score > maxScore:
            maxScore = score
            maxT = deepcopy(T)

for i in range(1, D + 1):
    print(maxT[i] + 1)
# print(score)


Measured memory_bytes: 89932
a,b = map(int,input().split())
res = list(map(int,input().split()))
votes = sum(res)
lvotes = votes / (4 * b)
cnt = b
for i in res:
    if cnt == 0:
        break
    if i >= lvotes:
        cnt -= 1
if cnt == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define ll long long
#define lsb(x) (x & -x)

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("a.in", "r", stdin);

    int n, w;
    cin >> n >> w;

    vector<int> dp(100000 + 1, w + 2);
    vector<int> a(n + 1, 0);
    vector<int> b(n + 1, 0);

    for(int i = 1; i <= n; i ++)
        cin >> a[i] >> b[i];

    int lim = 0;
    dp[0] = 0;
    for(int i = 1; i <= n; i ++) {
        for(int s = lim; s >= 0; s --)
            dp[s + b[i]] = min(dp[s + b[i]], dp[s] + a[i]);

        lim += b[i];
    }

    for(int i = lim; i >= 0; i --) {
        if(dp[i] <= w) {
            cout << i;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 640
#problem B
input_d21 = input()
N = int(input_d21)
wa = 0
for i in range(1,N+1):
    test3 = i % 3
    test5 = i % 5
    if test3 != 0 and test5 != 0:
        wa += i
    else:
        pass
print(wa)

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

using namespace std;

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

    int N;
    cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; ++i) cin >> H[i];
    vector<int> H_cnt(N);
    H_cnt[0] = 0;
    for (int i = 1; i < N; ++i) {
        if (H[i - 1] >= H[i]) H_cnt[i] = H_cnt[i - 1] + 1;
        else H_cnt[i] = 0;
    }
    cout << *max_element(H_cnt.begin(), H_cnt.end()) << '\n';
}

Measured memory_bytes: 1024
mod = 998244353

a,b,c,d = map(int,input().split())
ans = 0
dp = [[0]*(d+1) for i in range(c+1)]
mod = 998244353

dp[a][b] = 1
for i in range(a+1,c+1):
    dp[i][b] = dp[i-1][b] * b % mod # 縦にのばす
for i in range(b+1,d+1):
    dp[a][i] = dp[a][i-1] * a % mod # 横にのばす
#ここまでが単純に縦横のみ伸ばしていった時の状態

for i in range(a+1,c+1):
    for j in range(b+1,d+1):
        dp[i][j] = ((dp[i-1][j]*j) + (dp[i][j-1]*i) - (dp[i-1][j-1]*(i-1)*(j-1)))%mod 
#よこ⇒たてとたて⇒よこの順で選択した場合の重複を引く

print(dp[c][d])

Measured memory_bytes: 136472
x  = int(input())
if 599 >= x >=400:
  print(8)
elif 799>= x >= 600:
  print(7)
elif 999 >= x >= 800:
  print(6)
elif 1199 >= x >= 1000:
  print(5)
elif 1399 >= x >= 1200:
  print(4)
elif 1599 >= x >= 1400:
  print(3)
elif 1799 >= x >= 1600:
  print(2)
elif 1999 >= x >= 1800:
  print(1)

Measured memory_bytes: 61636
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <cmath>
#include <algorithm>
#include <vector>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main(){
  int N;
  cin>>N;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  sort(A.begin(),A.end());
  vector<int64_t>p;
  for(int i=N-1;i>=0;i--){
    if(A[i]==A[i-1]){
      p.push_back(A[i]);p.push_back(A[i-1]);i--;}
  }
  if(p.size()<4){cout<<0<<endl;}
  else{cout<<p[0]*p[2]<<endl;}
  return 0;
}

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

int main(){
  int a,b;
  int n;
  cin >> a >> b;
  if(a > b) n = a,--a;
  else n = b,--b;
  if(a > b) n = n + a;
  else n = n + b;
  cout << n;
  return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
	int N;
	cin >> N;
	vector<ll> A(N), B(N), C(N);
	REP(i, N) cin >> A[i];
	REP(i, N) cin >> B[i];
	REP(i, N) cin >> C[i];
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	sort(C.begin(), C.end());

	ll res = 0;
	REP(i, N){
		res += ((lower_bound(A.begin(), A.end(), B[i]) - A.begin()) * (N - (upper_bound(C.begin(), C.end(), B[i]) - C.begin())));
	}
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

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

int main(){
    int h, w;
    cin >> h >> w;
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<vector<int>> ans(h, vector<int>(w));
    int cnt = 0;
    int c_cnt = 1;
    rep(i, h) rep(j, w) {
        int w_idx = (i&1) ? w - 1 - j : j;
        ans[i][w_idx] = c_cnt;
        ++cnt;
        if (cnt == a[c_cnt-1]) {
            cnt = 0;
            ++c_cnt;
        }
    }
    rep(i, h) {
        rep(j, w) {
            if ( j != 0 ) cout << " ";
            cout << ans[i][j];
        }
        cout << endl;
    } 
    return 0;
}


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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

#define loop(i, n) for(int i = 0;i < n;i++)
#define IINF 2e9
#define MOD 1e9+7

int main(void){

    ll n;
    cin >> n;
    map<ll, int> mp;

    bool flag = true;

    if(n == 1){
        cout << 0 << endl;
        return 0;
    }

    if(n % 2 != 0){
        for(int i = 3;i <= sqrt(n);i += 2){
            if(n % i == 0){
                flag = false;
            }
        }

        if(flag){
            cout << 1 << endl;
            return 0;
        }
    }

    ll temp = n;
    while(temp % 2 == 0){
        mp[2]++;
        temp /= 2;
    }

    for(int i = 3;i <= sqrt(n);i++){
        while(temp % i == 0){
            mp[i]++;
            temp /= i;
        }
    }
    int ans = 0;

    if(temp != 1) ans++;

    for(auto m : mp){
        ans += (-1+sqrt(1+m.second*8))/2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3728
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  string s,t;
  cin >> s >> t;
  REP(i,s.length()){
    string s_new = s.substr(i)+s.substr(0,i);
    if(s_new==t){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;


int main(){
    int n;cin >>n;
    int ans;int now=-1;
    for (int i = 1; i <=n; ++i) {
        int c=i;
        int cnt=0;
        while(c%2==0){
            cnt++;
            c/=2;
        }
        if(now<cnt){
            ans=i;
            now=cnt;
        }
    }
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;



int main(){

	double n, t, a, h[1000], T=10000000;
	cin >> n >> t >> a;
	int ans;
	for(int i=0; i<n; i++){
		cin >> h[i];
		h[i]=t-h[i]*0.006;
		if(T>abs(a-h[i])){
			T=abs(a-h[i]);
			ans=i+1;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

const int MAX = 200000;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理として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;
    }
}

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    COMinit();
    ll n, k;
    cin >> n >> k;
    vector<vector<ll>> g(n);
    for (ll i = 0; i < n - 1; i++)
    {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    ll ans = k;
    vector<bool> seen(n, false);
    stack<ll> st;
    st.push(0);
    while (!st.empty())
    {
        ll p = st.top();
        st.pop();
        seen[p] = true;
        ll cnt = 0;
        for (auto v : g[p])
        {
            if (!seen[v])
            {
                st.push(v);
                if (p == 0)
                {
                    (ans *= (k - 1 - cnt)) %= MOD;
                }
                else
                {
                    (ans *= (k - 2 - cnt)) %= MOD;
                }
                cnt++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 12020
class SegmentTree(object):
    """
    セグメントツリー (0-indexed)

    1. 値の更新 O(logN)
    2. 区間クエリ O(logN)
    """
    def __BinOp(self, x, y):
        """ セグ木で使用する二項演算 """
        return x | y

    def __init__(self, init_ele, N:int):
        """
        セグ木を構築する

        init_ele: 単位元 
        N: 要素数
        """
        self.__init_ele = init_ele
        self.__n = 1
        while self.__n < N:
            self.__n <<= 1

        self.__dat = [init_ele] * (2 * self.__n)
    
    def update(self, k:int, x):
        """ k番目の値をxに変更する """
        k += self.__n - 1
        self.__dat[k] = x
        while k:
            k = (k - 1) // 2
            self.__dat[k] = self.__BinOp(
                self.__dat[k * 2 + 1], self.__dat[k * 2 + 2]
                )
    
    def query(self, p:int, q:int):
        """ 区間クエリ [p,q) """
        if q <= p: return self.__init_ele
        p += self.__n - 1
        q += self.__n - 2
        res = self.__init_ele
        while q - p > 1:
            if not (p & 1):
                res = self.__BinOp(res, self.__dat[p])
            if q & 1:
                res = self.__BinOp(res, self.__dat[q])
                q -= 1
            p = p // 2
            q = (q - 1) // 2
        res = self.__BinOp(res, self.__dat[p])
        if p != q: res = self.__BinOp(res, self.__dat[q])
        return res
    
    def get_num(self, k:int):
        """ k番目の値を取得する """
        k += self.__n - 1
        return self.__dat[k]

############################################################
N = int(input())

ST = SegmentTree(0, N)
for i, s in enumerate(list(input())):
    ST.update(i, 1 << (ord(s) - ord('a')))

Q = int(input())
for _ in range(Q):
    x,y,z = map(str,input().split())
    x = int(x); y = int(y)
    if x == 1:
        ST.update(y - 1, 1 << (ord(z) - ord('a')))
    else:
        z = int(z)
        print(bin(ST.query(y - 1, z)).count("1"))

Measured memory_bytes: 99472
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

/* define */
#define Yes(X) puts ( (X) ? "Yes" : "No")
#define YES(X) puts ( (X) ? "YES" : "NO")
#define FOR(i, a, b) for ( int i = (a); i < (b) ; i++)
#define REP(i, n) for ( int i = 0; i < (n) ; i++)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = 1000000007;

/* alias */
typedef long long ll;
typedef unsigned  u;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0) return Lgcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / Lgcd(a, b) * b;
}

/* main */

int main() {
	int n, m, c, a[20][20], b[20],r = 0;
	scanf("%d%d%d", &n, &m, &c);
	REP(i, m)scanf("%d", &b[i]);
	REP(i, n)REP(j, m)scanf("%d", &a[i][j]);
	REP(i, n) {
		int s = c;
		REP(j, m)s += a[i][j] * b[j];
		if (s > 0)r++;
	}
	printf("%d", r);
	return 0;
}


Measured memory_bytes: 128
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll,ll> mll;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
#define sf(n)     scanf("%lld",&n)
#define sff(n,m)     scanf("%lld %lld",&n,&m)
#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)
#define sfs(n)     scanf("%s",n)
#define pf(n)     printf("%lld\n",n)
#define pff(n,m)     printf("%lld %lld\n",n,m)
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
#define pfs(n)     printf("%s\n",n)
#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)
#define pb     push_back
#define prf     printf
#define inf     2e18
#define low     -1000000000000
#define PI        acos(-1.0)
#define rep1(i,n) for(i=1;i<n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe1(i,n) for(i=1;i<=n;i++)
#define repe0(i,n) for(i=0;i<=n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)

int main()
{
    ll i,t,k,j;
    double x,y,n,m;
    cin>>x>>y>>n>>m;
    n = n*30.0;
    n+= 0.5*m;
    m = m*6;
    n  =fabs(n-m);
    if(n>180)
        n = 360-n;

    cout<<fixed<<setprecision(15)<<sqrt(x*x+y*y-(2*x*y*cos(n*PI/180)))<<endl;
    return 0;
}



Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <map>
using namespace std;
vector<long> primes(long n){
    map<long,bool> mp;
    for(int i = 0;i<=n;i++){
        mp[i] = true;
    }
    vector<long> prime;
    prime.push_back(2);
    for(int i = 2;i<=n;i++){
        if(mp[i]){
            for(int j = 2*i;j<=n;j+=i){
                mp[j] = false;
            }
            if(i%5==1) prime.push_back(i);
        }
    } 
    return prime;
}
int main(){
    vector<long> prime = primes(55555);

    int n;
    cin >> n;
    for(int i = 0;i<n;i++){
        cout << prime[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 3712
#include<iostream>
#include<string.h>
#include<queue>
#include<map>
#include<vector>
#include <cstdlib>
#include<algorithm>
#include <cstdio>
#include <cctype>
using namespace std;
const long long INF=10000000000000LL;
typedef long long ll;
typedef pair<ll,ll> P;
ll N,Ma,Mb,K=1,C[45];
ll A[45],B[45];
ll T,a,b;
ll ans=0;
bool h,o;
//bool D[100005];
char str1[55][55],str2[55][55];
map<string,int> m;
vector<int> v[10];
ll dp[45][405][405];
int main(){
	cin>>N;
	if(N<1200)cout<<"ABC"<<endl;
	else cout<<"ARC"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int w, a, b;
	
	scanf("%d %d %d", &w, &a, &b);
	
	if(a < b){
		if( (a<b && (a+w)>b) || (a<(b+w) && (a+w)>(b+w)) )
			printf("0\n");
		else
			printf("%d\n", (a+w)-b<0?b-(a+w):(a+w)-b);
	}
	else if(b < a){
		if( (b<a && (b+w)>a) || (b<(a+w) && (b+w)>(a+w)) )
			printf("0\n");
		else
			printf("%d\n", (b+w)-a<0?a-(b+w):(b+w)-a);
	}
	else
		printf("0\n");
	
	return 0;
}


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

typedef unsigned long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

const double PI = acos(-1.0);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int INF = 1000 * 1000 * 1000;
const int MAX = 2000 * 1000 + 5;
const int MAX2 = 1000 * 1000 + 2;
const int MAX20 = MAX2 * 10;
const int mod = 998244353;
int add(int a , int b)
{
	return a + b >= mod ? a + b - mod : a + b;
}
int mult(int a, int b)
{
	return a * (LL) b % mod;
}
int sub(int a , int b)
{
	return a - b < 0 ? a - b + mod : a - b;
}
int n;
string s;
string y;
int x[200005] , f[200005];
int main()
{
	cin >> n;
	y.resize(n);
	cin >> s;
	for(auto &x : s)
		x -= '0';
	for(int i = 1; i <= SZ(s); i++)
		x[i] = add(mult(x[i - 1] , 2) , s[i - 1]);
	int ans = 0;
	vector<int> divs;
	
	for(int d = 1; d <= n; d++) if(n % d == 0 && (n / d) % 2 == 1)
	{
		int cnt = x[d];
		for(int i = 0; i < n; i++)
			y[i] = s[i % d] ^ ((i / d) & 1);
		if(y <= s)
			cnt = add(cnt , 1);
		f[d] = cnt;
		for(auto x : divs)
			if(d % x == 0)
				f[d] = sub(f[d] , f[x]);
		divs.PB(d);
		ans = add(ans , mult(d , f[d]));
	}
	
	cout << mult(ans , 2);
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 1668
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int m=sc.nextInt();
    int c=sc.nextInt();
    int[] a=new int[m];
    int[] b=new int[m];
    for(int i=0;i<m;i++){
      b[i]=sc.nextInt();
    }
    int ans=0;
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
        a[j]=sc.nextInt();
      }
      int sum=0;
      for(int j=0;j<m;j++){
        sum+=a[j]*b[j];
      }
      sum+=c;
      if(sum>0){
        ans++;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23892
# -*- coding: utf-8 -*-
"""
Contents   : AtCoder Grand Contest 024 B問題 WA
Author     : Kitaura Hiromi
LastUpdate : 20180520
Since      : 20180520
"""
N = int(input())
p = [int(input()) for i in range(N)]
q = [0 for i in range(N)]
for i in range(N):
    q[p[i]-1] = i

cnt = 1
max_cnt = 1
for i in range(N-1):
    if q[i+1] > q[i]:
        cnt += 1
    else:
        max_cnt = max(max_cnt, cnt)
        cnt = 1
max_cnt = max(max_cnt, cnt)
print(N - max_cnt)

Measured memory_bytes: 18888
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define MAX 10000
#define INFTY (1 << 29)

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];
    	}
};

class Edge {
	public:
	int source, target, cost;
	Edge(int source = 0, int target = 0, int cost = 0):
	source(source), target(target), cost(cost) {}
	bool operator < (const Edge &e) const {
		return cost < e.cost;
	}
};

int kruskal(int N, vector<Edge> edges) {
	int totalCost = 0;
	sort(edges.begin(), edges.end());
	
	DisjointSet dset = DisjointSet(N);
	
	for(int i = 0; i < N; i++) dset.makeSet(i);
	
	int source, target;
	for(int i = 0; i < edges.size(); i++) {
		Edge e = edges[i];
		if(!dset.same(e.source, e.target)) {
			totalCost += e.cost;
			dset.unite(e.source, e.target);
		}
	}
	return totalCost;
}

int main() {
	int N, M, cost;
	int source, target;
	
	cin >> N >> M;
	
	vector<Edge> edges;
	for(int i = 0; i < M; i++) {
		cin >> source >> target >> cost;
		edges.push_back(Edge(source, target, cost));
	} 
	
	cout << kruskal(N, edges) << endl;
	
	return 0;
}

Measured memory_bytes: 5440
#include<bits/stdc++.h>
using namespace std;
#define l1 long long
int main(){
    int n; cin>>n;
   string str; cin>>str; int c=0;
   for(int i=0;i<n-2;i++){
    if(str[i]=='A' && str[i+1]=='B' && str[i+2]=='C')c++;
   }
    cout<<c;
}


Measured memory_bytes: 3612
N,M,K= list(map(int, input().split()))
C = []
A = []
for _ in range(N):
    c= list(map(int, input().split()))
    C.append(c[0])
    A.append(c[1:])
inf = float('inf')
ans = inf

for i in range(2**N):
    re = [0]*M
    count = 0
    for j in range(N):
        if((i>>j)&1):
            count += C[j]
            for k in range(M):
                re[k] += A[j][k]
    
    flag = True
    for n in range(M):
        if re[n] < K:
            flag = False
    
    if flag:
        ans = min(ans,count)

if ans == inf:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 68280
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;

int main()
{
    //std::string a;
    string A;
    string B;
    int C;
    int D;
    string E;
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> D;
    cin >> E;
    if (E == A) C = C - 1;
    else D = D -1;
    cout<< C << " " << D << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
#define int long long
signed main()
{
    int r;cin >> r;
    if(r < 1200)puts("ABC");
    else if(r < 2800)puts("ARC");
    else puts("AGC");
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int comp(const void *p1,const void *p2){
  int n1=*(const int *)p1;
  int n2=*(const int *)p2;
  return n2-n1;
}

int main(void){
  int N,K,contest=0;
  char str[16];
  int num[26]={0};
  int i,j,k;

  scanf("%d%d%*c",&N,&K);
  for(i=0;i<N;i++){
    scanf("%s%*c",str);
    num[str[0]-'A']++;
  }

  do{
    qsort(num,26,sizeof(int),comp);
    for(i=0;i<K;i++){
      if(num[i]==0){
	printf("%d\n",contest);
	return 0;
      }
      num[i]--;
    }
    contest++;
  }while(1);
      

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){

  int hh, ww, h, w;
  cin >> hh >> ww >> h >> w;
  cout << hh * ww - (h * ww + w * hh - h * w) << endl;

  return 0;
}


Measured memory_bytes: 256
#define M 1000000007
#define Rep(i,a,n)for(int i=a;i<n;i++)
typedef long long L;
L mp(L a,L n,L m){L x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define imp(b,p)mp(b,p-2,p)
main(){
  L s,f[2009]={1},a=0;
  scanf("%lld",&s);
  if(s>2){
    Rep(i,1,2009)f[i]=f[i-1]*i%M;
    Rep(n,1,1+s/3)a+=f[s-2*n-1]%M*imp(f[n-1],M)%M*imp(f[s-3*n],M)%M;
  }
  printf("%lld",a%M);
}

Measured memory_bytes: 1740
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    int h[100010];
    int dp[100010];
    cin >> N;
    memset(dp,0,sizeof(dp));
    for(int i=0;i<N;i++) cin >> h[i];
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for(int i=1;i<N;i++){
        dp[i+1] = min(dp[i] + abs(h[i]-h[i+1]),dp[i-1] + abs(h[i-1]-h[i+1]));
    }
    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input!(s: chars);
    let mut set = BTreeSet::new();
    for i in 0..4 {
        set.insert(s[i]);
    }

    println!("{}", if set.len() == 2 { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};


bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  string S;
  cin >> S;
  map<char,int> mp;
  if(S == "zyxwvutsrqponmlkjihgfedcba")
    cout << -1 << endl;
  else{
    REP(i,S.size())mp[S[i]]++;
    if(S.size() < 26){
      for(char c = 'a';c<='z';c++){
        if(mp[c] == 0){
          cout << S << c << endl;
          return 0;
        }
      }
    }else{
      string D = S;
      next_permutation(S.begin(),S.end());
      REP(i,D.size()){
        if(S[i] != D[i]){
          cout << S.substr(0,i+1) << endl;
          return 0;
        }
      }
      

    }

  }
  
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

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

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
const int MOD = 1000000007;
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Optional;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Integer[] num=new Integer[new Scanner(System.in).nextInt()];
		for(int i=1;i<=num.length;i++) {
			num[i-1]=i;
		}
		Optional<Integer> maxdivision=Arrays.asList(num)
				.stream()
				.map(Main::countCanDivideBy2)
				.max(Integer::compare);
		int result=(int) Math.pow(2d,maxdivision.get().doubleValue());
		System.out.println(result);
	}
	public static int countCanDivideBy2(Integer i) {
		int result=0;
		for(;i%2==0&&i>0;result++) {
			i/=2;
		}
		return result;
	}
}

Measured memory_bytes: 29012
#include<bits/stdc++.h>
using namespace std;
int dp[100000+1][3];
int n;
int vac(int v[][3],int ind,int f){
      if(ind==n) return 0 ;
      
      if(f==-1){
            return max(v[ind][0]+vac(v,ind+1,0),max(v[ind][1]+vac(v,ind+1,1),v[ind][2]+vac(v,ind+1,2)));
      }
      if(dp[ind][f]!=-1) return dp[ind][f];
      if(f==0){
            return dp[ind][f]=max(v[ind][1]+vac(v,ind+1,1),v[ind][2]+vac(v,ind+1,2));
      }
      if(f==1)
      return dp[ind][f]=max(v[ind][0]+vac(v,ind+1,0),v[ind][2]+vac(v,ind+1,2));
      if (f==2)
      return dp[ind][f]=max(v[ind][1]+vac(v,ind+1,1),v[ind][0]+vac(v,ind+1,0));
      
      
}
int main(){
  int i,j;
  memset(dp,-1,sizeof(dp));
  cin>>n;
  int v[n][3];
  for(i=0;i<n;i++){
    for(j=0;j<3;j++)        
    cin>>v[i][j];
  }
  int ans=vac(v,0,-1);
  cout<<ans;
  
 
}
  
  

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,a,b,now;
vector<pair<int,int>> v;

signed main() {
    cin >> n;
    rep(i,n) {
        cin >> a >> b;
        v.pb(mp(b,a));
    }
    sort(all(v));
    for(auto i : v) {
        now += i.se;
        if (now > i.fi) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}






Measured memory_bytes: 6256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func sum(slice []int) int {
    total := 0
    for _, n := range slice {
        total += n
    }
    return total
}

func main() {
    sc.Split(bufio.ScanWords)

    n, m := nextInt(), nextInt()
    a := nextIntArr(n)
    sortIntsRev(a)

    threshold := float64(sum(a)) / float64((4 * m))

    count := 0
    for _, c := range a{
        if threshold <= float64(c) {
            count++
        }
    }

    if count >= m {
        fmt.Println("Yes")
    } else {
        fmt.Println("No")
    }
}


// Library

func nextLine() string {
    sc.Scan()
    return sc.Text()
}

func nextInt() int {
    sc.Scan()
    i, _ := strconv.Atoi(sc.Text())
    return i
}

func nextIntArr(n int) []int {
    var a []int
    for i := 0; i < n; i++ {
        a = append(a, nextInt())
    }
    return a
}

// 数値を桁区切りのスライスにする
func digit(n int, list []int) []int {
   if n > 0 {
       return digit(n/10, append(list, n%10))
   }
   return list
}

func sortIntsRev(list []int) {
    sort.Sort(sort.Reverse(sort.IntSlice(list)))
}

func strReverse(s string) string {
    runes := []rune(s)
    for i := 0; i < len(s)/2; i++ {
        runes[i], runes[len(s)-1-i] = runes[len(s)-1-i], runes[i]
    }
    return string(runes)
}



Measured memory_bytes: 640