akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
    int n, m;
    cin >> n >> m;
    
    bool sw[m][n] = {};

    rep(i, m){
        int k;
        cin >> k;
        rep(j, k){
            int s;
            cin >> s;
            sw[i][s-1] = true;
        }
    }

    bool p[m];
    rep(i, m)cin >> p[i];

    int ans = 0;
    rep(i, (1<<n)){
        bool isOK = true;
        rep(j, m){
            bool isODD = false;
            rep(k, n)if(i&(1<<k)&&sw[j][k])isODD = !isODD;
            if(p[j]!=isODD){
                isOK = false;
                break;
            }
        }
        
        if(isOK)ans++;
    }

    cout << ans << endl;
}

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

int main()
{
    int n;
    cin >> n;
    int a[n], i, cnt = 0;
    for(i=0; i<n; i++)
        cin >> a[i];

    for(int i=0; i<n; i += 2)
    {
        if(a[i]%2)
            cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

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

  int a, b, c;
  cin >> a >> b >> c;

  cout << max(0, c - (a - b)) << endl;

  return 0;
}

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

int main(void){
    int A, B; cin >> A >> B;

    if (A <= 5) {
        cout << 0 << endl;
    }else if (A <= 12) {
        cout << B/2 << endl;
    }else {
        cout << B << endl;
    }

    return 0;
}

Measured memory_bytes: 256
fn solve(s: &Vec<char>, idx: usize, memo: &mut HashMap<usize, (usize, usize)>) -> (usize, usize) {
    if idx == s.len() {
        return (1, 0);
    }
    let mut x = 0;
    let mut cnt = 0;
    let mut sum = 0;
    for i in idx..s.len() {
        x = x * 10 + (s[i] as u8 - b'0') as usize;
        let (lcnt, lsum) = solve(s, i + 1, memo);
        cnt += lcnt;
        sum += lsum + lcnt * x;
    }
    memo.insert(idx, (cnt, sum));
    memo[&idx]
}
fn main() {
    let s: Vec<char> = readln();
    let mut m = HashMap::new();
    let (_, ans) = solve(&s, 0, &mut m);
    println!("{}", ans);
}

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n {
        vs.push(readln());
    }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(
    String,
    bool,
    f32,
    f64,
    isize,
    i8,
    i16,
    i32,
    i64,
    usize,
    u8,
    u16,
    u32,
    u64
);
impl<T> FromLn for Vec<T>
where
    T: FromLn,
{
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);


Measured memory_bytes: 4352
import Data.List
import Data.Char
import Control.Monad
import Data.Ord

main = do
  s <- getLine
  let d = map digitToInt s
  let d' = [a*100+b*10+c|i<-[0..(length d)-3],let a=d!!i,let b=d!!(i+1),let c=d!!(i+2)]
  let d'' = map (\x -> (x,abs (753-x))) d'
  let d0 = head $ sortBy (comparing snd) d''
  putStrLn $ show $ snd d0


Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
int n,cnt;
map<string,int> mp;
string s;
int main() {
    scanf("%d",&n);
    for(int i=0;i<n;i++) {
        cin>>s;
        if(mp[s]==0)
            cnt++;
        mp[s]=1;
    }
    cout<<cnt<<endl;
}



Measured memory_bytes: 19292
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	N *=2;
	vector<int> L(N);
	for(int i =0; i < N; i++) cin >> L[i];
	sort(begin(L),end(L));
	int ans =0;
	for(int i =N-2; i >= 0; i -=2) ans +=L[i];
	cout << ans << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,a,b,c,d;
int main(){
	while(true){
		cin>>n;if(n==0)break;c=0;d=0;
		for(int i=0;i<n;i++){
			cin>>a>>b;
			if(a>b)c+=(a+b);
			if(a<b)d+=(a+b);
			if(a==b){c+=a;d+=b;}
		}
		cout<<c<<' '<<d<<endl;
	}
	return 0;
}

Measured memory_bytes: 3076
/** I can do this all day **/

#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;

typedef long long                   ll;
typedef long double                 ld;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define endl                        "\n"

//void add(int I, int value){seg[I += MAXN] = value;for (I >>= 1; I; I >>= 1){seg[I] = __gcd(seg[I << 1], seg[I << 1 | 1]);}}

//int query(int l, int r){int ans = seg[l + MAXN];for (l += MAXN, r += MAXN + 1; l < r; l >>= 1, r >>= 1){if(l & 1) ans = __gcd(ans, seg[l ++]);if(r & 1) ans = __gcd(ans, seg[-- r]);}return ans;}

const int MAXN = 1e6 + 10;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 8e18;
const int LOG = 22;

ll pw(ll a , ll b, ll mod)  { return (!b ? 1 : (b & 1 ? (a * pw(a * a % mod, b / 2, mod)) % mod : pw(a * a % mod, b / 2, mod))); }

set < ll > Ans;

int main(){
    fast_io;
    //cout << fixed << setprecision(15);
    //scanf("%d %d %f %lld %s %c", &x);
    //printf("%d %d %f %lld %s %c", x);
    ll n;
    cin >> n;
    if(n == 2)
    {
            cout << 1 << endl;
            return 0;
    }
    vector < ll > D;
    ll n2 = n - 1;
    for(ll i = 2; i * i <= n2; i++)
    {
            if(n2 % i == 0)
            {
                    if(n2 / i != i)
                    {
                            Ans.insert(n2 / i);
                    }
                    Ans.insert(i);
            }
    }
    Ans.insert(n);
    Ans.insert(n2);
    for(ll i = 2; i * i <= n; i++)
    {
            if(n % i == 0)
            {
                    if(n / i != i)
                    {
                            D.push_back(n / i);
                    }
                    D.push_back(i);
            }
    }
    for(auto x : D)
    {
            ll cu = n;
            while(cu % x == 0)
            {
                    cu /= x;
            }
            if(cu % x == 1)
            {
                    Ans.insert(x);
            }
    }
    ll O = (int)Ans.size();
    cout << O;
    return 0;
}



Measured memory_bytes: 384
def main():
    s = input()
    a, b, c, d = s
    ops = ["+", "-"]
    for op1 in ops:
        for op2 in ops:
            for op3 in ops:
                expr = a + op1 + b + op2 + c + op3 + d
                if eval(expr) == 7:
                    print(expr + "=7")
                    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<stdio.h>

typedef struct{
  int k;
  int pk;
  int lk;
  int rk;
} Heap;

#define MAX 251

Heap A[MAX];

int main(){
  int i,H;

  for(i=1;i<=H;i++){
    A[i].pk=NULL;
    A[i].lk=NULL;
    A[i].rk=NULL;
  }

  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i].k);

    if(i/2>=1){
      A[i].pk=A[i/2].k;
      if(i%2==0)
	A[i/2].lk=A[i].k;
      else
	A[i/2].rk=A[i].k;
    }
  }

  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i].k);
    if(A[i].pk!=NULL)
      printf("parent key = %d, ",A[i].pk);
    if(A[i].lk!=NULL)
      printf("left key = %d, ",A[i].lk);
    if(A[i].rk!=NULL)
      printf("right key = %d, ",A[i].rk);
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,0,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;


 
signed main(){
    int N,M;cin>>N>>M;
    int H[N];
    REP(i,N)cin>>H[i];
    vector<int>G[N];
    REP(i,M){
        int a,b;cin>>a>>b;a--;b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    int ans=0;
    REP(i,N){
        int nowh=H[i];
        bool ok=true;
        for(auto v:G[i]){
          if(H[v]>=nowh){
                ok=false;
                break;
            }
        }
        if(ok)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 10260
#include "bits/stdc++.h"
using namespace std;

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

	char S[3], T[3];
	for (int i = 0; i < 3; i++)
		cin >> S[i];
	for (int i = 0; i < 3; i++)
		cin >> T[i];

	int total = (S[0] == T[0]) + (S[1] == T[1]) + (S[2] == T[2]);

	cout << total;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000007
int u[111100];
vector<int>i;
vector<int>y;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d=0,e;
  cin >>a>>b;
  if(a>b) c=a,a--;
  else c=b,b--;
  if(a>b) c+=a;
  else c+=b;
  cout <<c<<'\n';
  return (0);
}


Measured memory_bytes: 380
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a[100005], b[100005], c[100005];
ll e[100005], d[100005];
int n;
int main(){
	scanf("%d", &n);
	for (int i = 1; i <= n; ++ i) scanf("%lld", &a[i]);
	for (int i = 1; i <= n; ++ i) scanf("%lld", &b[i]);
	for (int i = 1; i <= n; ++ i) scanf("%lld", &c[i]);
	sort(a + 1, a + n + 1);
	sort(b + 1, b + n + 1);
	sort(c + 1, c + n + 1);
	int j = n;
	for (int i = n; i; i --) {
		while (j && c[j] > b[i]) j --;
		d[i] = n - j + d[i + 1];
	}
	j = n;
	for (int i = n; i; i --) {
		while (j && b[j] > a[i]) j --;
		e[i] = d[j + 1] + e[i + 1];
	}
	cout << e[1] << endl;
	return 0;
}

Measured memory_bytes: 4096
# https://atcoder.jp/contests/abc042/submissions/9653489

import itertools
N, K = input().split()
P = input().split()

#使える数字
a= sorted(set([str(i) for i in range(10)])-set(P))
#同じ桁
b1 = itertools.product(a, repeat=len(N))
#繰り上がって一つ大きい桁
b2 = itertools.product(a, repeat=len(N)+1)
ans=str()
cnt=0
for i in b1:
  #print(type(i))
  ans = "".join(i)
  if N <= ans:
    print(ans)
    cnt=1
    break
if cnt==0:
  for i in b2:
    ans = "".join(i)
    #print(ans)
    if "0"+N <= ans:
      print(ans)
      break

Measured memory_bytes: 3064
from scipy.sparse import csr_matrix
from scipy.sparse.linalg import spsolve
import numpy as np

N = int(input())
A = np.array(input().split())

#値の入る座標の準備
rows = np.concatenate([np.arange(N), np.arange(N)])
cols = np.concatenate([np.arange(N), np.arange(1,N+1) % N])

#疎行列の作成
#csr_matrix((値だけのlist, 値の入る座標を示すtulpe:(rows, cols) ), 大きさ (N,N))
mat = csr_matrix(([1] * (2*N), (rows, cols)), (N,N))
#print(rows,cols,mat)
 
answer = (spsolve(mat,A) * 2).astype(int)
print(*answer)


Measured memory_bytes: 66020
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	int h,w;
	cin >> h >> w;
	vector<string> grid(h);
	for(int i = 0;i < h;i++)cin >> grid[i];

	vector<vector<bool>> gf(h,vector<bool>(w,false));
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			if(grid[i][j] == '#'){
				int dx[4] = {0,1,0,-1};
				int dy[4] = {1,0,-1,0};

				for(int k = 0;k < 4;k++){
					int nx = j + dx[k];
					int ny = i + dy[k];
					if(0 <= nx && nx < w && 0 <= ny && ny < h && grid[ny][nx] == '#'){
						gf[i][j] = true;
						gf[ny][nx] = true;
					}
				}
			}
		}
	}

	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			if(grid[i][j] == '#' && gf[i][j] == false){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int year[2],month[2],day[2];
    while(cin>>year[0]>>month[0]>>day[0]>>year[1]>>month[1]>>day[1]){
        bool en=0;
        for(int i=0;i<2;i++)if(year[i]<0||month[i]<0||day[i]<0)en=1;
        if(en)break;
        int ans=0;
        for(int i=year[0];i<=year[1];i++){
            ans+=365;
            if(i%4==0&&i%100!=0||i%400==0)ans+=1;
        }
        if((year[0]%4==0&&year[0]%100!=0||year[0]%400==0)&&month[0]>=2)ans-=1;
        if((year[1]%4==0&&year[1]%100!=0||year[1]%400==0)&&month[1]<=2)ans+=1;
        for(int i=1;i<month[0];i++){
            if(i==2)ans-=28;
            else if(i==4||i==6||i==9||i==11)ans-=30;
            else ans-=31;
        }
        for(int i=month[1];i<13;i++){
            if(i==2)ans-=28;
            else if(i==4||i==6||i==9||i==11)ans-=30;
            else ans-=31;
        }
        ans+=day[1]-day[0];
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main(){
  int n,cnt=0;
  cin >> n;
  while(1){
    if(n<=3){
      cnt++;
      break;
    }
    if(n%3==0){
      n/=3;
    }
    else if(n%3==1){
      n+=2;
      n/=3;
    }
    else{
      n+=1;
      n/=3;
    }
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int main(){
    int K, N;
    cin >> K >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    int max_div = K-A[N-1] + A[0];
    for(int i=0; i<N-1; i++) {
        max_div = max(max_div, A[i+1]-A[i]);
    }
    cout << K - max_div << endl;
}

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N, M; cin >> N >> M;
  vector<vector<ll>> nbr(N);
  for (ll i = 0; i < M; i++) {
    ll a, b; cin >> a >> b; a--; b--;
    nbr.at(a).push_back(b);
    nbr.at(b).push_back(a);
  }
  vector<ll> dist(N, -1);
  vector<ll> mark(N, 0);
  using Tuple = tuple<ll, ll, ll>; // dist, this, orig
  queue<Tuple> que;
  for (ll i : nbr.at(0)) {
    que.emplace(1, i, 0);
  }
  while (!que.empty()) {
    auto [dis, t, orig] = que.front(); que.pop();
    if (dist.at(t) >= 0) continue;
    mark.at(t) = orig;
    dist.at(t) = dis;
    for (ll i : nbr.at(t)) {
      if (dist.at(i) < 0) {
	que.emplace(dis+1, i, t);
      }
    }
  }
  cout << "Yes\n";
  for (ll i = 1; i < N; i++) {
    cout << mark.at(i) + 1 << "\n";
  }

  return 0;

}



Measured memory_bytes: 17732
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define eps 1e-10
using namespace std;

int main()
{
	ll s,a,b,c,d;
	cin>>s; cout<<0<<" "<<0<<" ";
	a=1e9; if(s%a==0) b=s/a; else b=s/a+1;
	ll s2=a*b-s; cout<<a<<" "<<1<<" "<<s2<<" "<<b<<endl;
	return 0;
}

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

int main() {
  int k[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  int n;
  cin >> n;
  cout << k[n-1] << endl;

  return 0;
}


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


#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

ll mod = 1e9 + 7ll;
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; }
const ll inf = 1ll << 60;

vector<int> value; // ノードの値を持つ配列
int n, m;
int s=1; //葉の数
vector<pair<int, int>> work;

void update(int i, int x) {
    // i 番目の葉の値を x に変える
    i += s - 1; // i 番目の葉のノード番号
    value[i] = x;
    while (i > 0) {
        i = (i - 1) / 2; // ノード i の親ノードの番号に変える
        value[i] = max(value[i * 2 + 1],
                       value[i * 2 + 2]); // 左右の子の max を計算しなおす
    }
}

int query(int a, int b, int k, int l, int r) {
    // [a, b) の区間に対するクエリについて
    // ノード k （区間 [l, r) 担当）が答える
    if (r <= a || b <= l) return -1; // 区間が被らない場合は -1 を返す
    if (a <= l && r <= b)
        return value[k]; // ノード k の担当範囲がクエリ区間 [a, b)
                         // に完全に含まれる
    else {
        int c1 = query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子に値を聞く
        int c2 = query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子に値を聞く
        return max(c1, c2); // 左右の子の値の max を取る
    }
}

int main() {
    cin >> n >> m;
    while(1<<s < m) s++;
    s = 1<<s;
    value = vector<int>(2 * s - 1, -1);
    rp(i, 0, m){
        update(i, i);
    }
    rp(i, 0, n){
        int a, b;
        scanf("%d%d", &a, &b);
        work.emplace_back(b, a);
    }
    ll ans = 0ll;
    sort(work.rbegin(), work.rend());
    rp(i, 0, work.size()){
        int a = work.at(i).second;
        int b = work.at(i).first;
        int t = query(0, m-a+1, 0, 0, s);
        if(t >= 0){
            ans += b;
            update(t, -1);    
        }
    }
    printf("%lld", ans);
    return 0;
    
}

Measured memory_bytes: 2424
/*
[abc140] C - Maximal Value
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

const int MAX_N = 100;

int N;
int B[MAX_N - 1];

ll solve() {
    int ans = 0;
    for (int i = 1; i < N - 1; i++) {
        ans += min(B[i - 1], B[i]);
    }
    ans += B[0] + B[N - 2];

    return ans;
}

int main() {
    cin >> N;
    for (int i = 0; i < N - 1; i++) {
        cin >> B[i];
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<62;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
set<P> st;

int main(){
	cin>>n;
	st.insert({0,1});
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		auto it=st.lower_bound({x,inf});
		if(it==st.begin()){
			cout<<"No"<<endl;
			continue;
		}
		it--;
		int l=it->first,r=it->second;
		st.erase(it);
		if(l<=x&&x<r){
			if(l!=x) st.insert({l,x});
			if(x+1!=r) st.insert({x+1,r});
		}
		else{
			if(l!=r-1) st.insert({l,r-1});
			st.insert({r,x+1});
		}
		cout<<"Yes"<<endl;
	}
}

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

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

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

  int count = 0;
  while(1) {
    bool odd_flag = false;
    for(int i=0; i<n; i++) {
      if(a[i] % 2 != 0) odd_flag = true;
    }

    if(odd_flag) break;

    for(int i=0; i<n; i++) {
      a[i] /= 2;
    }
    count++;
  }

  cout << count << endl;
}

Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <numeric>

typedef long long ll;
#define INF 1 << 29
#define LLINF 1LL << 60
#define EPS 1e-6
#define ALL(c) (c).begin(), (c).end()
#define CNT(c,x) count(ALL(c),x)
#define dump(x)  cerr << #x << " = " << (x) << endl;
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

using namespace std;

vector<pair<int, int> > g[100010];
int col[100010];

void dfs(int u, int pw, int pb){
  for(int i = 0; i < g[u].size(); i++){
    int v = g[u][i].first, w = g[u][i].second;
    if(col[v] != -1) continue;
    if((pw + w) % 2 == 0){
      col[v] = 0;
      dfs(v, 0, pb + w);
    }else{
      col[v] = 1;
      dfs(v, pw + w, 0);
    }
  }
  return;
}

int main(){
  int N; cin >> N;
  for(int i = 0; i < N - 1; i++){
    int u, v, w; cin >> u >> v >> w;
    u--, v--;
    g[u].push_back(make_pair(v, w));
    g[v].push_back(make_pair(u, w));
  }

  FILL(col, -1);
  
  col[0] = 0;
  dfs(0, 0, 0);
  for(int i = 0; i < N; i++) cout << col[i] << endl;
  return 0;
}


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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i) 
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

constexpr static int MOD = 1000000000 + 7;
constexpr static int inf = INT_MAX / 2;
constexpr static llong INF = 1LL << 31;
constexpr static int dx[] = {1, 0, -1, 0};
constexpr static int dy[] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    vector<llong> A(n);
    rep(i, n) cin >> A[i];
    sort(all(A));
    vector<pair<llong, int> > CB(m);
    rep(i, m) {
        int b;
        llong c;
        cin >> b >> c;
        CB[i] = make_pair(c, b);
    }
    sort(allr(CB));

    int itr = 0;
    llong ans = 0;
    bool flag = true;
    for (int i = 0; i < n; ++i) {
        if (! flag) {
            ans += A[i];
        } else {
            if (CB[itr].first < A[i]) {
                ans += A[i];
                flag = false;
            } else {
                ans += CB[itr].first;
                --CB[itr].second;
                if (CB[itr].second == 0) {
                    ++itr;
                    if (itr >= m) flag = false;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct Tree
{
	int L,R,minn1,minn2;
}T[8000005];
inline void Build(int L,int R,int v)
{
	T[v].L=L;T[v].R=R;
	T[v].minn1=T[v].minn2=0x3FFFFFFF;
	if(L==R)return;
	int mid=(L+R)>>1;
	Build(L,mid,v<<1);
	Build(mid+1,R,(v<<1)|1);
	return;
}
inline void pushup(int v)
{
	T[v].minn1=min(T[v<<1].minn1,T[(v<<1)|1].minn1);
	T[v].minn2=min(T[v<<1].minn2,T[(v<<1)|1].minn2);
	return;
}
inline void Insert(int x,int minn1,int minn2,int v)
{
	if(x>T[v].R||x<T[v].L)return;
	if(T[v].L==T[v].R)
	{
		T[v].minn1=min(T[v].minn1,minn1);
		T[v].minn2=min(T[v].minn2,minn1+minn2);
		return;
	}
	Insert(x,minn1,minn2,v<<1);
	Insert(x,minn1,minn2,(v<<1)|1);
	pushup(v);
	return;
}
inline int Query1(int L,int R,int v)
{
	if(L>T[v].R||R<T[v].L)return 0x3FFFFFFF;
	if(L<=T[v].L&&R>=T[v].R)return T[v].minn1;
	return min(Query1(L,R,v<<1),Query1(L,R,(v<<1)|1));
}
inline int Query2(int L,int R,int v)
{
	if(L>T[v].R||R<T[v].L)return 0x3FFFFFFF;
	if(L<=T[v].L&&R>=T[v].R)return T[v].minn2;
	return min(Query2(L,R,v<<1),Query2(L,R,(v<<1)|1));
}
struct Node
{
	int L,R;
}q[200005];
inline bool cmp(const Node& a,const Node& b)
{
	if(a.L!=b.L)return a.L<b.L;
	else return a.R<b.R;
}
int f[200005],s[200005],b[200005];
int main(void)
{
	int i,n,m,sum=0,ans=0x3FFFFFFF;
	scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d",&b[i]),sum+=b[i];
	for(i=1;i<=n;++i)s[i]=s[i-1]+(b[i]==0?1:-1);
	scanf("%d",&m);
	for(i=1;i<=m;++i)scanf("%d%d",&q[i].L,&q[i].R);
	sort(q+1,q+m+1,cmp);
	f[0]=sum;
	Build(0,n,1);
	Insert(0,f[0],s[0],1);
	for(i=1;i<=m;++i)
	{
		f[i]=min(Query1(0,q[i].L-1,1)+s[q[i].R]-s[q[i].L-1],Query2(q[i].L,q[i].R,1)+s[q[i].R]);
		Insert(q[i].R,f[i],-s[q[i].R],1);
	}
	for(i=0;i<=m;++i)ans=min(ans,f[i]);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 12544
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let r: i32 = read(&mut stdin_lock, &mut buf, b'\n');
    let ans = 3 * r * r;
    println!("{}", ans);
}


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

int main(int argc, char* argv[]) {
    int n, u, k, v;
    cin >> n;
    int G[n][n];

    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            G[i][j] = 0;
        }
    }

    for (int i = 0; i < n; i++){
        cin >> u >> k;
        for (int j = 0; j < k; j++){
            cin >> v;
            G[i][v-1] = 1;
        }
    }

    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            cout << G[i][j];
            if (j != n-1) cout << " ";
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3104
n,m,k = map(int,input().split())
for a in range(n+1):
    # a行押す
    black = a * m
    for b in range(m+1):
        # b列押す
        res = black + b * (n - 2 * a)
        if res == k:
            print('Yes')
            exit()
print('No')


Measured memory_bytes: 2940
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
long long int xor1(long long int a)
{
    if(a%4==1)
    {
        return 1;
    }
    else if(a%4==2)
    {
        return a+1;
    }
    else if(a%4==3||a==0)
    {
        return 0;
    }
    else
        return a;
}
int main()
{
    long long int a,b;
    cin>>a>>b;
    if(a==0)
    {
        cout<<b<<endl;
        return 0;
    }
    if(b==0)
    {
        cout<<a<<endl;
        return 0;
    }
    long long int sum=xor1(a-1)^xor1(b);
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 384
n=int(input())
l=list(map(int,input().split()))
i=n-1
flag=False
while 1<=i and i<=n-1:
    if l[i]+2<=l[i-1]:
        print('No')
        flag=True
        break
    elif l[i]+1==l[i-1]:
        l[i-1]-=1
        i-=1
    else:
        i-=1
if flag==False:
    print('Yes')

Measured memory_bytes: 63856
#include <iostream>
#include <vector>
#include <stack>
#include <string>
#include <cmath>
#include <sstream>
#include <queue>
#include <map>
#include <cstring>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
using namespace std;


int main() {
    double R1, R2;
    cin >> R1 >> R2;
    printf("%.10lf\n",  R1 * R2 / (R1 + R2));
}


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

n = int(input())

dp = [0] * (n+1)

for i in range(0, n+1):
  dp[i] = i
  six = 6
  nine = 9
  while True:
    if i - six >= 0:
      dp[i] = min(dp[i], dp[i-int(six)]+1)
      six *= 6
    else:
      break
  while True:
    if i - nine >= 0:
      dp[i] = min(dp[i], dp[i-int(nine)]+1)
      nine*= 9
    else:
      break
#print(*dp)
print(dp[-1])  


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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

//repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

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

    int m = min(a, b);
    int M = max(a, b);

    string str;
    REP(i, M) {
      str.append(to_string(m));
    }
    ANS(str);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int i,n;
    scanf("%d",&n);
    
    int a[n];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    
    for(i=n-1;i>=0;i--){
        printf("%d",a[i]);
        if(i != 0){ //最後ではないならば空白を入れる
            printf(" ");
        }
    }
    printf("\n");
    return 0;
}



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

int main() {
  int N;
  string S;
  cin >> N >> S;
  
  int ans = 0;
  int flag = 0;
  for(int i=0; i<N-2; i++){
    if(S.at(i) == 'A'){
      if(S.at(i+1) == 'B'){
        if(S.at(i+2) == 'C') ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>

int arr[200000];

int main() {
  int N, M;

  scanf("%d %d", &N, &M);

  for (int i = 0; i < M; i++) {
    int L, R;
    scanf("%d %d", &L, &R);
    arr[L]++; arr[R + 1]--;
  }

  int t = 0;
  for (int i = 1; i <= N; i++) {
    arr[i] += arr[i - 1];
    if (arr[i] == M) t++;
  }

  printf("%d\n", t);
}

Measured memory_bytes: 760
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
const int MAXI = 110;

int main() {
	int h, w; cin >> h >> w;
	vector<vector<char> > s(h + 1, vector<char>(w + 1));
	REP(i, h) REP(j, w)
		cin >> s[i+1][j+1];

	vector<vector<int> > dp(MAXI, vector<int>(MAXI, INT_MAX));
	dp[1][1] = (s[1][1] == '#');

	for (int i = 1; i <= h; i++) for (int j = 1; j <= w; j++) {
		if (i != 1)
			dp[i][j] = min(dp[i][j], dp[i-1][j] + (s[i-1][j]=='.' && s[i][j]=='#'));
		if (j != 1)
			dp[i][j] = min(dp[i][j], dp[i][j-1] + (s[i][j-1]=='.' && s[i][j]=='#'));
	}
	cout << dp[h][w] << '\n';
	return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int c = a * b;
    if(c % 2)cout<<"Odd"<<endl;
    else cout<<"Even"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;
int n;
long long ans ;
vector <int> a[nax];

void dfs (int nod, int parent) {

    /**
        number of pair that nod connect with parent
    */


    long long c = 0;
    if (parent > 0) {
        int f = min(nod, parent);
        int g = max(nod, parent);
        c = 1LL * f * (n - g + 1);
    } else c = 0;

    ans += (1LL * nod * (nod + 1) / 2) - c;

    for (int i : a[nod]) {
        if (i != parent)
            dfs(i, nod);
    }

}

int main () {
    scanf("%d", &n);

    for (int i = 1 ; i < n ; ++ i) {
        int u, v;
        scanf("%d %d", &u, &v);
        a[u].push_back(v);
        a[v].push_back(u);
    }

    dfs(1, 0);

    printf("%lld\n", ans);
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 26408
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

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

	vector<int> A(N);
	for(int i=0; i<N; i++)
		cin >> A[i];

	vector<int> b(N, 0);
	for(int i=0; i<N; i++)
		b[A[i]]++;

	bool ok = true;
	if(N%2 == 1 && b[0] != 1)
		ok = false;
	for(int i=N%2+1; i<N; i+=2)
	{
		if(b[i] != 2)
		{
			ok = false;
			break;
		}
	}
	if(ok != true)
	{
		cout << 0 << endl;
		return 0;
	}

	const long long mod = 1E9 + 7;
	long long ret = 1;
	for(int i=0; i<N/2; i++)
	{
		ret *= 2;
		ret %= mod;
	}

	cout << ret << endl;

	return 0;
}


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

using namespace std;

const int N = 1e5 + 10;

int a[N];
int b[N];
int c[N];

long long dp[N][3];

int main() {

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

    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for(int i = 1 ; i < n ; i++) {
        dp[i][0] = a[i] + max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = b[i] + max(dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] = c[i] + max(dp[i - 1][0], dp[i - 1][1]);
    }


    cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]}) << '\n';

    return 0;
}

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

#define filein freopen ("in.txt", "r", stdin)
#define fileout freopen ("out.txt", "w", stdout)
#define dbg(x) cerr << #x << ": " << x << endl

using namespace std;
typedef long long ll;

const int maxn = 100005;
const ll mod = 1000000007;

char s[maxn];
int n;
ll dp[maxn][15];

ll go (ll id, ll rem){
    if (id == n) return (rem == 5);
    ll &ret = dp[id][rem];
    if (ret != -1) return ret;
    ret = 0;
    if (s[id] == '?')
    for (ll i = 0; i <= 9; i++){
        ret += go (id + 1, ((rem * 10) + i) % 13);
        ret %= mod;
    }
    else{
        ret += go (id + 1, ((rem * 10) + s[id] - '0') % 13);
        ret %= mod;
    }
    return ret;
}

int main(){
    scanf ("%s", s);
    n = strlen (s);
    memset (dp, -1, sizeof dp);
    cout << go (0, 0) << '\n';
    return 0;
}


Measured memory_bytes: 18304
def calc(x):
    ret = 0
    while x % 100 ==0:
        x /= 100
        ret += 1
    return ret

D, N = map(int, input().split())

cnt = 0
val = 0

while cnt < N:
    val += 1
    if calc(val) == D:
        cnt += 1

print(val)


Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define rrep(i,m,n) for(int i = m; i >= n; i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll A[200010];
    cin >> N;
    rep(i,0,N){
        cin >> A[i];
    }
    ll lv = 0;
    ll left_value = A[0], right_value = 0;
    // ll diff = abs(A[0]-A[1]);
    ll diff_max[200010] = {};
    ll diff_min[200010] = {};
    rep(mid,1,N-2){
        right_value += A[mid];
        while(mid - lv > 1){
            // print(abs(right_value - left_value));
            // print(abs(right_value - left_value - 2 * A[lv]));
            if(abs(right_value - left_value) > abs(right_value - left_value - 2 * A[lv+1])){
                lv++;
                right_value -= A[lv];
                left_value += A[lv];
            }else{
                break;
            }
        }
        diff_max[mid] = max(right_value, left_value);
        diff_min[mid] = min(right_value, left_value);
    }
    left_value = 0, right_value = A[N-1];
    ll diff_max2[200010] = {};
    ll diff_min2[200010] = {};
    lv = N-2;

    rrep(mid, N-3, 1){
        left_value += A[mid+1];
        while(lv - mid > 1){
            if(abs(right_value - left_value) > abs(right_value - left_value + 2*A[lv])){
                right_value += A[lv];
                left_value -= A[lv];
                lv--;
            }else{
                break;
            }
        }
        diff_max2[mid] = max(right_value, left_value);
        diff_min2[mid] = min(right_value, left_value);
    }
    ll ans = INF;
    rep(i,1,N-2){
        ll max_val = max(diff_max[i], diff_max2[i]);
        ll min_val = min(diff_min[i], diff_min2[i]);
        ans = min(ans, max_val - min_val);
    }
    print(ans);
}


Measured memory_bytes: 8064
import sys
s = input()
c= 0
for i in range((len(s))//2):
    if (s[i] != s[(len(s)-1)//2-i-1]) or (s[(len(s)-1)//2+i+1] != s[len(s)-i-1]) or s[i]!=s[len(s)-i-1]:
        c = 0
        break
    else:
        c +=1

if c >0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
using System;
namespace DynammicProgramming {
	class Frog1 {
    	public static void Main(String[] args) {
          int n = Int32.Parse(Console.ReadLine());
          int[] stones = new int[n];
          int[] dp = new int[n];
          string[] input = Console.ReadLine().Split(' ');
          for(int i = 0; i < stones.Length; i++) {
            stones[i] = Int32.Parse(input[i]);
          }
          dp[0] = 0;
          dp[1] = Math.Abs(stones[0]-stones[1]);
          for(int i = 2; i < stones.Length; i++) {
            int oneBefore = Math.Abs(stones[i-1]-stones[i])+dp[i-1];
            int twoBefore = Math.Abs(stones[i-2]-stones[i])+dp[i-2];
            dp[i] = Math.Min(oneBefore, twoBefore);
          }
          Console.WriteLine(dp[stones.Length-1]);
        }
    }
}

Measured memory_bytes: 16864
// https://atcoder.jp/contests/abc054/tasks/abc054_c

#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>

using namespace std;

int dfs(const vector<vector<int>>& edges, int current, unordered_set<int>& visited) {
	visited.insert(current);
	if (visited.count(current) > 0 && visited.size() == edges.size()) {
		visited.erase(current);
		return 1;
	}
	int res = 0;
	for (int edge : edges[current]) {
		if (visited.count(edge) > 0) {
			continue;
		}
		res += dfs(edges, edge, visited);
	}
	visited.erase(current);
	return res;
}

int main (int argc, char* argv[]) {
	int n, m;
	cin >> n >> m;

	vector<vector<int>> edges(n);
	for (int i = 0; i < m; i++) {
		int from, to;
		cin >> from >> to;
		from--; to--;
		edges[from].push_back(to);
		edges[to].push_back(from);
	}

	unordered_set<int> visited;
	cout << dfs(edges, 0, visited) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a, b) << ' ' << max(b - (n - a), 0) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n, s, ans = 0, min=0, k;

  int back(int x, int z, int max);

  scanf("%d %d", &n, &s);
  while(n != 0 || s != 0)
    {
      for(k=0; k<n; k++) min = min + k;
      if(s < min) printf("0\n");
      else
        {
          ans = back(n, s - min, n-1);
          printf("%d\n", ans);
        }
      ans = 0;
      min = 0;
      scanf("%d %d", &n, &s);
    }
  return 0;
}

int back(int x, int z, int max){
  int kaeri=0, l;
  if(max > 9) return 0;
  if(z < 0) return 0;
  if(z == 0) return 1;
  for(l=1; l<=x; l++)
    {
      kaeri = kaeri + back(l, z-l, max+1);
    }
  return kaeri;
}

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

int main(){
  int n,k;cin>>n>>k;
  vector<int> p(n);
  for (auto && a : p) {
    cin >> a;
  }

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

  int ans = 0;

  for (int i = 0; i < k; i++) {
    ans += p.at(i);
  }

  cout << ans << endl;

}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<vector> 
using namespace std;
int main() {
    int n,cnt=0;
    cin >> n;
    int p[n];
    for (int i=0; i<n; i++)
        cin >> p[i];
    for (int i=0; i<n-2; i++) {
        if (( p[i] > p[i+1] && p[i+2] < p[i+1] ) ||
            ( p[i] < p[i+1] && p[i+2] > p[i+1] ))
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    k, s = map(int, input().split())
    res = 0
    for x in range(k + 1):
        for y in range(k + 1):
            z = s - x - y
            if 0 <= z <= k:
                res += 1
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
n = gets.to_i               #駒の個数
x = gets.split.map &:to_i   #駒の位置

m = gets.to_i               #操作する駒の数
a = gets.split.map &:to_i   #操作する駒の位置

max = 2020

#すごろくマスの作成・初期化
sugoroku = []

for i in 0..max do
    sugoroku[i] = 0
end

sugoroku[0] = "offset"
sugoroku[max] = "goal"


#駒の配置
j = 0
for i in 1..max do
    if i == x[j]
        sugoroku[i] = 1
        j += 1
    end
end

#駒の操作
for i in 0...m do
    if  sugoroku[ x[ a[i] - 1] + 1 ] == 0
        sugoroku[ x[ a[i] - 1] + 1 ] = 1
        sugoroku[ x[ a[i] - 1] ] = 0
        
        x[ a[i] - 1 ] += 1
    end
end

for i in 0...max do
    if sugoroku[i] == 1
        puts i
    end
end



Measured memory_bytes: 6892
#include <iostream>

using namespace std;

void printProbabilityOfGettingMoreHeads(long double headsProbabilityArray[], int numberOfCoins)
{
    long double dpArr[numberOfCoins+1][numberOfCoins+1];
    for(int i = 0 ; i <= numberOfCoins ; i++)
    {
        for(int j = 0 ; j <= numberOfCoins ; j++)
        {
            dpArr[i][j] = 0.00000000000;
        }
    }
    dpArr[0][0] = 1.0000000000;
    for(int i = 1 ; i <= numberOfCoins ; i++)
    {
        for(int j = 0 ; j <= i ; j++)
        {
            if(!j)
            {
                dpArr[i][j] = dpArr[i-1][j] * (1 - headsProbabilityArray[i-1]);
            }
            else
            {
                dpArr[i][j] = (dpArr[i-1][j-1] * headsProbabilityArray[i-1]) + (dpArr[i-1][j] * (1 - headsProbabilityArray[i-1]));
            }
        }
    }
    long double probability = 0.0000000000;
    for(int i = (numberOfCoins/2) + 1 ; i <= numberOfCoins ; i++)
    {
        probability += dpArr[numberOfCoins][i];
    }
    printf("%.10Lf\n", probability);
}

int main(int argc, const char * argv[])
{
    int numberOfCoins;
    cin>>numberOfCoins;
    long double headsProbabilityArray[numberOfCoins];
    for(int i = 0 ; i < numberOfCoins ; i++)
    {
        cin>>headsProbabilityArray[i];
    }
    printProbabilityOfGettingMoreHeads(headsProbabilityArray, numberOfCoins);
    return 0;
}


Measured memory_bytes: 140928
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    R = int(readline())

    if R < 1200:
        ans = 'ABC'
    elif R < 2800:
        ans = 'ARC'
    else:
        ans = 'AGC'

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9056
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  
  long long int X;
  cin >> X;
  
  long long int A=0, B=0;
  bool finish = false;
  
  while(true){
    for(long long int i=-A; i<=A; i++){
      B = i;
      if(pow(A,5) - pow(B,5) == X){
        finish = true;
        break;
      }
    }
    if(finish){
      break;
    }
    A++;
  }
  
  cout << A << " " << B << endl;
}

Measured memory_bytes: 4072
#include<stdio.h>
int main(){
	int a,b,c,d,e,f,g;
	int z[4][3][10]={0};
	scanf("%d",&a);
	for(b=0;b<a;b++){
		scanf("%d %d %d %d",&c,&d,&e,&f);
		z[c-1][d-1][e-1]+=f;
	}
	for(a=0;a<4;a++){
	for(b=0;b<3;b++){
	for(c=0;c<10;c++){
		printf(" %d",z[a][b][c]);
	}
	printf("\n");
	}
	if(a!=3)
	printf("####################\n");
	}
return 0;
}

Measured memory_bytes: 612
import { isRegExp } from "util";

class AtCoder {
  // 入力系
  input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);
  input_i=-1;

  n(){
    this.input_i++;
    return Number(this.input[this.input_i]);
  }
  nn(n:number):number[]{
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.n());
    }
    return a;
  }
  s(){
    this.input_i++;
    return String(this.input[this.input_i]);
  }
  ss(n:number):string[]{
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.s());
    }
    return a;
  }

  // コンソール
  o(...a:any){
    console.log(...a);
  }

  // Math
  abs(a:number){
    return Math.abs(a);
  }
  min(...a:number[]){
    return Math.min(...a);
  }
  max(...a:number[]){
    return Math.max(...a);
  }
  floor(a:number){
    return Math.floor(a);
  }
  ceil(a:number){
    return Math.ceil(a);
  }
  round(a:number){
    return Math.round(a);
  }

  // ソート
  asc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return a-b});
  }
  desc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return b-a});
  }

  // 自作
  gcd(...arr:number[]):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=x;
    }
    return arr[arr.length-1];
  };
  lcm(...arr:number[]):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=arr[i]*arr[i+1]/x;
    }
    return arr[arr.length-1];
  };
  isPrime(n:number):boolean{
    if(n < 2) return false;
    const suq=Math.sqrt(n);
    for(let i=2;i<=suq;i++){
      if(n%i==0){
        return false;
      }
    }return true;
  };
  deduplicate(a:any[]):any[]{
    return Array.from(new Set(a));
  };
  f(roop:number, callback:any){
    for(let i=0;i<roop;i++){
      callback(i);
    }
  };
  Yes(){
    console.log('Yes');
  }
  No(){
    console.log('No');
  }
  YES(){
    console.log('YES');
  }
  NO(){
    console.log('NO');
  }
}
const m = () => {
  const o = new AtCoder();
  let [n,k]=o.nn(2)
  let ar=o.nn(n)
  o.asc(ar)
  for(let i=0;i<k;i++){
    ar.pop()
  }
  let ans=0;
  for(let i=0;i<ar.length;i++){
    ans+=ar[i]
  }
  o.o(ans)
}
m();

Measured memory_bytes: 38448