akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  vector<string> A={"Sunny","Cloudy","Rainy","Sunny"};
  string s;
  cin>>s;
  for(int i=0;i<3;i++){
    if(A[i]==s){cout<<A[i+1]<<endl; return 0;}
  }


  return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {

        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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


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

fn main() {
    input! {
        s: String
    }
    if s.len() == 3 {
        println!("{}", s.chars().rev().collect::<String>())
    } else {
        println!("{}", s);
    }
}


Measured memory_bytes: 4352
#include<stdio.h>

int H[500001],size;

int left(int l){
  return 2*l;
}

int right(int r){
  return 2*r+1;
}

void maxheapify(int h[],int i){
  int largest,ln,rn,an;
  ln=left(i);
  rn=right(i);

  if(ln<=size && h[ln]>h[i]){
    largest=ln;
  }

  else largest=i;

  if(rn<=size && h[rn]>h[largest]){
    largest=rn;
  }

  if(largest!=i){
    an=h[largest];
    h[largest]=h[i];
    h[i]=an;
    maxheapify(h,largest);
  }
}

void Buildmaxheap(int h[]){
  int i;
  for(i=size/2;i>=1;i--){
    maxheapify(h,i);
  }
}

int main(){
  int i;

  scanf("%d",&size);
  for(i=1;i<=size;i++){
    scanf("%d",&H[i]);
  }

  Buildmaxheap(H);

  for(i=1;i<=size;i++){
    printf(" %d",H[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 2552
#include"stdio.h"
int main(){
    int N,K,R,S,P,score=0;
    char T[100001];
    scanf("%d%d%d%d%d%s",&N,&K,&R,&S,&P,T);
    for(int i=0;i<N;i++){
        if(i<K){
            char t=T[i];
            if(t=='r'){
                score+=P;
            }
            if(t=='s'){
                score+=R;
            }
            if(t=='p'){
                score+=S;
            }
        }
        else{
            char t=T[i],s=T[i-K];
            if(t=='r'){
                if(s=='r') T[i]='e';
                else score+=P;
            }
            if(t=='s'){
                if(s=='s') T[i]='e';
                else score+=R;
            }
            if(t=='p'){
                if(s=='p') T[i]='e';
                else score+=S;
            }
        }
    }
    printf("%d",score);
}

Measured memory_bytes: 1808
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
#include <queue>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vstr=vector<string>;

// トポロジカルソート
// グラフ、頂点の入次数、頂点数を受け取り、そのトポロジカルソートを記録した配列を返す関数
vll topological_sort(vvll &G, vll &indeg, ll V) {
    vll ret;
    queue<ll> que;
    // for(ll in:indeg) {
    rep(i,V){
        if(indeg[i]==0) que.push(i);
    }
    while(!que.empty()){
        ll u = que.front();
        que.pop();
        for(auto v:G[u]){
            indeg[v]--;
            if(indeg[v]==0) que.push(v);
        }
        ret.pb(u);
    }
    return ret;
}

void solve() {
    ll N,M;
    cin >> N >> M;
    vvll to(N);
    vll indegree(N);
    ll a,b;
    rep(i,N+M-1){
        cin >> a >> b;
        a--;b--;
        to[a].pb(b);
        indegree[b]++;
    }
    vll sorted_v = topological_sort(to,indegree,N);
    ll head = sorted_v[0];
    vll ans(N,0);
    rep(i,N){
        ll u = sorted_v[i];
        for(auto v:to[u]){
            ans[v] = u+1;
        }   
    }
    rep(i,N){
        print(ans[i]);
    }
}
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(n+10);
  for ( int i = 0; i < n; ++ i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  for ( int i = 0; i < n; ++ i) {
    if( i+2 > a[i+1]) {
      int ret = 0;
      for ( int k = i+1; a[k] == i+1; ++ k) {
        ret ^= 1;
      }
      ret |= (a[i]-i+1)&1;
      cout << (ret ? "First\n" : "Second\n");
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 640
N,M = map(int,input().split())
es = []
for i in range(M):
    a,b = map(int,input().split())
    a,b = a-1, b-1
    es.append((a,b))
 
parent = None
def root(a):
    if parent[a] == a:
        return a
    else:
        parent[a] = root(parent[a])
        return parent[a]
def is_same(a,b):
    return root(a) == root(b)
def unite(a,b):
    ra = root(a)
    rb = root(b)
    if ra == rb: return
    parent[ra] = rb;
 
ans = 0
for i in range(M):
    parent = [k for k in range(N)]
    for j,e in enumerate(es):
        if j == i: continue
        a,b = e
        unite(a,b)
    a,b = es[i]
    if not is_same(a,b):
        ans += 1
print(ans)

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

int main() {
	int n, m,a[50],b[50],c[50],d[50],temp[50];

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

	for (int i = 0; i < n; i++) {
		int sum = abs(a[i]-c[0])+abs(b[i]-d[0]);
		temp[i] = 1;
		for (int j = 1; j < m; j++) {
			int div= abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if (sum > div) {
				sum = div;
				temp[i] = j + 1;
			}
		}
	}
	for (int i = 0; i < n; i++)cout << temp[i] << endl;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> s(M);
  vector<char> c(M);
  for(int i=0;i<M;i++)  cin >> s.at(i) >> c.at(i);

  if(M==0){
    if(N==1)  cout << 0 << endl;
    else cout << pow(10,N-1) << endl;
    return 0;
  }

  if(N==1){
    bool flag=true;
    for(int i=0;i<M-1;i++)  if(c.at(i)!=c.at(i+1))  flag=false;
    if(flag)  cout << c.at(0) << endl;
    else  cout << -1 << endl;
    return 0;
  }

  for(int i=pow(10,N-1);i<pow(10,N);i++){
    string tmp=to_string(i);
    bool flag=true;
    for(int j=0;j<M;j++){
      if(tmp.at(s.at(j)-1) != c.at(j))  flag=false;
    }
    if(flag){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    cout << (a+b)%24 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
#include <cmath>
#include <cstdio>
#include <complex>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
P cnte[114514],cnto[114514];
int main() {
  ll n;
  cin>>n;
  ll a;
  const ll N=1e5;
  for(int i=0;i<N;i++){
    cnte[i].second=i;
    cnto[i].second=i;
  }
  for(int i=0;i<n;i++){
    cin>>a;
    a--;
    if(i%2)cnto[a].first++;
    else cnte[a].first++;
  }
  sort(cnte,cnte+N);
  sort(cnto,cnto+N);
  ll ans=n;
  if(cnte[N-1].second==cnto[N-1].second){
    ans-=max(cnte[N-1].first+cnto[N-2].first,cnte[N-2].first+cnto[N-1].first);
  }else ans-=cnte[N-1].first+cnto[N-1].first;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3328
#include <iostream>

using namespace std;

int main()
{
    int n , cnt = 0 ;
    cin >> n ;
    int a[n] ;
    for(int i = 0 ; i < n ; ++i)
    {
        cin >> a[i];
    }
    for(int i = 0 ; i < n ; i+=2)
    {
        if(a[i]%2 != 0)
            cnt++ ;
    }
    cout << cnt ;

    return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct SegmentTree {
  vector<Pi> data;
  int n, sz;
  SegmentTree(const vint& a) {
    n = a.size();
    sz = 1; while(sz < n) sz <<= 1;
    data.resize(2*sz-1, Pi(inf, inf));
    rep(i, n) data[i+sz-1] = Pi(a[i], i);
    for(int i = sz-2; i >= 0; --i) data[i] = min(data[2*i+1], data[2*i+2]);
  }
  Pi query(int a, int b, int k, int l, int r) {
    if(r <= a || b <= l) return Pi(inf, inf);
    if(a <= l && r <= b) return data[k];
    Pi vl = query(a, b, 2*k+1, l, (l+r)/2);
    Pi vr = query(a, b, 2*k+2, (l+r)/2, r);
    return min(vl, vr);
  }
  Pi query(int a, int b) {
    return query(a, b, 0, 0, sz);
  }
};

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;
  vint even, odd;
  rep(i, n) {
    int a;
    cin >> a;
    int b = inf;
    if(i&1) swap(a, b);
    even.push_back(a);
    odd.push_back(b);
  }

  SegmentTree eseg(even), oseg(odd);
  priority_queue<Tapris, vector<Tapris>, greater<Tapris> > que;
  que.emplace(eseg.query(0, n).first, 0, n);
  vint ans;
  while(!que.empty()) {
    Tapris tap = que.top(); que.pop();
    int vl, l, r;
    tie(vl, l, r) = tap;
    Pi p = (l%2 ? oseg : eseg).query(l, r);
    Pi q = (l%2 ? eseg : oseg).query(p.second, r);
    ans.push_back(p.first);
    ans.push_back(q.first);
    int nl = p.second, nr = q.second;
    if(l+1 < nl) que.emplace((l%2 ? oseg : eseg).query(l, nl).first, l, nl);
    if(nl+1+1 < nr) que.emplace(((nl+1)%2 ? oseg : eseg).query(nl+1, nr).first, nl+1, nr);
    if(nr+1+1 < r) que.emplace(((nr+1)%2 ? oseg : eseg).query(nr+1, r).first, nr+1, r);
  }
  rep(i, n) cout << ans[i] << " \n"[i==n-1];

  return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 100001

int gcd(int a, int b) {
    if(a < b) swap(a, b);
    if (b==0) return a;
    return gcd(b, a%b);
}

int main() {
    int k,s,z, ans=0;
    cin >> k >> s;
    for(int i=0; i<=k; i++) {
        for(int j=0; j<=k; j++) {
            z = s-(i+j);
            if(z>=0 and z<=k) ans ++;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
from functools import lru_cache

@lru_cache(maxsize=1<<10)
def solve(p, q, a, n):
    def _solve(num, dem, d, m, s):
        if num == 0:
            return 1
        if d == 0:
            return 0
        if num * a // m < dem:
            return 0
        return sum((_solve(num*i-dem, dem*i, d-1, m*i, i)
                    for i in range(s, min(dem*n//num, a//m)+1)), 0)
    return _solve(p, q, n, 1, 1)

if __name__ == "__main__":
    ans = []
    while True:
        p, q, a, n = [int(i) for i in input().split()]
        if p == 0:
            break
        ans.append(solve(p, q, a, n))
    print(*ans, sep="\n")    

Measured memory_bytes: 8704
N, K = map(int, input().split())
V = list(map(int, input().split()))

answer = 0
for i in range(min(N + 1, K + 1)):
  for j in range(i + 1):
    left = j
    right = i - j
    
    q = []
    for k in range(left):
      q.append(V[k])
    for k in range(N - right, N):
      q.append(V[k])
    q.sort()
    
    tmp = sum(q)
    for k in range(min(K - i, len(q))):
      if q[k] < 0:
        tmp -= q[k]
      else:
        break
    answer = max(answer, tmp)
    
print(answer)

Measured memory_bytes: 41584
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = int(sys.stdin.readline().rstrip())
    lines = [int(sys.stdin.readline().rstrip()) for _ in range(N)]
    print(len(set(lines)))


if __name__ == '__main__':
    main()


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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const int INF = 100000000;


int main() {

    ll N;
    cin >> N;
    vector<ll> A(N), copy(N);
    REP(i, N)cin >> A[i];

    ll ans = 0;
    copy = A;
    ll count = 0;
    REP(i, N){
        if(A[i]<0)count++;
        A[i] = abs(A[i]);
    }
    sort(A.begin(), A.end());

    // cout << count << endl;
    if(count % 2 ==0){
        REP(i, N)ans += A[i];
    }else{
        REP1(i, N)ans += A[i];
        ans -= A[0];
    }

    cout << ans << endl;

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


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

const int MOD = 1000000007;
const int MAX =200000;

int main() {
  int a, b;
  int ans = -1;
  double num1, num2;
  cin >> a >> b;
  for (int i = 1; i <= 1000; i++) {
    num1 = (double)i * 8 / 100;
    num2 = (double)i * 10 / 100;
    if((double)a <= num1 && num1 < (double)a + 1 && (double)b <= num2 && num2 < (double)b + 1) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import Control.Arrow
import qualified Data.ByteString.Char8 as B
import qualified Data.IntSet as S
import Data.List
import Text.Printf

readInt :: B.ByteString -> Int
readInt = maybe undefined fst . B.readInt

readIntPair :: B.ByteString -> [(Int, Int)]
readIntPair = map (pair . map readInt . B.words) . B.lines

pair :: [t] -> (t, t)
pair [x, y] = (x, y)
pair _ = undefined

main = do
  [x1,y1,x2,y2] <- map read . words <$> getLine
  _ <- getLine
  xys <- readIntPair <$> B.getContents
  printf "%.12f" (walk x1 y1 x2 y2 xys :: Double)

walk x1 y1 x2 y2 xys = 100*s - (20 - 5*pi)*p + (10*pi - 20)*q
  where
    [xmin,xmax] = sort [x1,x2]
    [ymin,ymax] = sort [y1,y2]
    cand = filter (\(x,y) -> xmin<=x && x<=xmax && ymin<=y && y<=ymax) xys
    s = fromIntegral $ abs (x2-x1) + abs (y2-y1)
    k = genericLength $ lis $ (if signum ((x2-x1) * (y2-y1)) == -1 then map negate else id) $ map snd $ sort cand
    (p, q) = (fromIntegral *** fromIntegral) $ if k < min (abs (x2-x1)) (abs (y2-y1)) + 1 then (k, 0) else (k - 1, 1)

lis :: [Int] -> [Int]
lis = S.toList . snd . foldl go (S.empty, S.empty)
  where
    go (acc, acc0) x = case S.lookupGT x acc of
      Nothing -> let acc1 = S.insert x acc in (acc1, acc1)
      Just g -> (S.insert x (S.delete g acc), acc0)


Measured memory_bytes: 84348
# -*- coding: utf-8 -*-
import time
import numpy as np

start = time.time()
limit_time = 1.8

# 整数の入力
d = int(input())
c = [int(i) for i in input().split()]
s = [[int(i) for i in input().split()] for j in range(d)]

c_num = np.array(c)
s_num = np.array(s)

def point(t):
    result = 0
    map = {
        0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0,
        10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0, 17: 0, 18: 0, 19: 0,
        20: 0, 21: 0, 22: 0, 23: 0, 24: 0, 25: 0
    }
    for i in range(d):
        comp = t[i] - 1
        day = i + 1
        map[comp] = day
        result = result + s[i][comp]
        for cc in range(26):
            result = result - c[cc] * (day - map[cc])
    return result

t = np.argmax(s_num, axis=1) + 1

print("\n".join([str(i) for i in t]))

Measured memory_bytes: 27484
#include<bits/stdc++.h>
//#define long long ll ;
#define mod 1e+9;
#define rep for(int i=0;i<n;i++);
#define pb push_back;
#define popb pop_back;
using namespace std;
const int ma=1e6+9;
typedef long long ll;
 
int main()
{
//     #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
   ios_base::sync_with_stdio(0);
    cin.tie(0);
    int k;
    cin >>k;
    ll cnt=0;
  int i;
    for( i=1;i<=k;i++)
    {
      cnt=(cnt*10+7)%k;
      if(cnt%k==0)
      {
         break;
      }
    }
    if(i==k+1)
    {
      if(cnt%k==0)
        cout << i << endl;
      else
      cout <<"-1" <<endl;
    }
    else
      cout << i << endl;
 
  }

Measured memory_bytes: 3608
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		List<Task> list = new ArrayList<>();
		for(long i = 0; i < n; i++) {
			list.add(new Task(sc.nextLong(), sc.nextLong()));
		}
		list.sort(Comparator.comparing(Task::getSime));
		boolean flag = true;
		long time = 0;
		for(Task tmp : list) {
			time += tmp.getSagyou();
			if(time > tmp.getSime()) {
				flag = false;
				break;
			}
		}
		if(flag) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}

class Task {
	private long sagyou;
	private long sime;

	protected Task(long sagyou, long sime) {
		super();
		this.sagyou = sagyou;
		this.sime = sime;
	}

	public long getSagyou() {
		return sagyou;
	}

	public void setSagyou(long sagyou) {
		this.sagyou = sagyou;
	}

	public long getSime() {
		return sime;
	}

	public void setSime(long sime) {
		this.sime = sime;
	}

}

Measured memory_bytes: 162264
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

	n := nextInt()
	p := make([]int, n)
	for i := 0; i < n; i++ {
		p[i] = nextInt()
	}

	c := 0
	for i := 0; i < n-2; i++ {
		if (p[i] < p[i+1] && p[i+1] < p[i+2]) || (p[i] > p[i+1] && p[i+1] > p[i+2]) {
			c++
		}
	}

	fmt.Println(c)
}

Measured memory_bytes: 640
n=float(input())
import math

if math.modf(n / 1.08)[0] == 0:
    ans = math.floor(n / 1.08)
else:
    ans = math.floor(n / 1.08) + 1

if math.floor(ans * 1.08) == n:
    print(ans)
else:
    print(':(')

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

using namespace std;

int main() {
    int n, m; cin >> n >> m;
    
    int h[100005];
    for (int i = 1; i <= n; i++) cin >> h[i];
    
    vector<int> adj[100005];
    for (int i = 0; i < m; i++) {
        int x, y; cin >> x >> y;
        adj[x].push_back(h[y]);
        adj[y].push_back(h[x]);
    }
    
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (adj[i].size() != 0) {
            sort(adj[i].rbegin(), adj[i].rend());
            if (h[i] > adj[i][0]) ans++;
        }
        else ans++;
    }
    
    cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 9132
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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

int n, src, dest, ans;
vector<vector<int>> gr;
vector<vector<int>> dist;

void bfs(int str, int type) {
	dist[str][type] = 0;
	queue<int> q;
	q.push(str);

	while (!q.empty()) {
		int parent = q.front();
		q.pop();
		bool is_leaf = true;

		for (auto child : gr[parent]) {
			if (dist[child][type] == INT_MAX) {
				is_leaf = false;
				dist[child][type] = dist[parent][type] + 1;
				q.push(child);
			}
		}

		if (type == 1 and is_leaf == true and dist[parent][0] < dist[parent][1]) {
			ans = max(ans, dist[parent][1]);
		}
	}
}

int main() {

	cin >> n >> src >> dest;
	gr.resize(n + 1);
	dist.resize(n + 1, vector<int>(2, INT_MAX));

	for (int i = 1; i <= n - 1; i++) {
		int u, v; cin >> u >> v;
		gr[u].push_back(v);
		gr[v].push_back(u);
	}

	if (src == dest) {
		cout << 0;
		return 0;
	}

	bfs(src, 0);
	bfs(dest, 1);

	cout << ans - 1;

	return 0;
}

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

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

ll calc_score(long long D, const std::vector<long long> &c, const std::vector<std::vector<long long>> &s,
              const std::vector<long long> &t, vector<set<ll>> &last) {
  ll score = 0;
  REP(d, D) {
    ll i = t[d] - 1;
    score += s[d][i];
    last[i].insert(d + 1);
    REP(j, 26) {
      score -= c[j] * (d + 1 - *last[j].rbegin());
    }
  }
  return score;
}

ll area(const set<ll> &last, ll d) {
  auto it = last.lower_bound(d);
  auto x = *it - d;
  it--;
  auto y = d - *it;
  return x * y;
}

ll calc_diff(const std::vector<long long> &c, const std::vector<std::vector<long long>> &s, ll d, vector<set<ll>> &last,
             ll pre, ll next) {
  ll diff = s[d - 1][next] - s[d - 1][pre];
  {
    auto it = last[next].insert(d).first;
    it++;
    auto n = *it;
    it--;
    it--;
    auto p = *it;
    ll x = n - d;
    ll y = d - p;
    diff += c[next] * x * y;
  }
  {
    last[pre].erase(d);
    diff -= c[pre] * area(last[pre], d);
  }
  return diff;
}

void solve(long long D, std::vector<long long> c, std::vector<std::vector<long long>> s, std::vector<long long> t,
           long long M, std::vector<long long> d, std::vector<long long> q) {
  vector<set<ll>> last(26);
  REP(j, 26) {
    last[j].insert(0);
  }
  ll score = calc_score(D, c, s, t, last);
  REP(j, 26) {
    last[j].insert(D + 1);
  }
  REP(i, M) {
    ll pre = t[d[i] - 1] - 1;
    ll next = q[i] - 1;
    t[d[i] - 1] = next + 1;

    score += calc_diff(c, s, d[i], last, pre, next);
    printf("%lld\n", score);
  }
}

int main() {
  long long D;
  scanf("%lld", &D);
  std::vector<long long> c(26);
  for (int i = 0; i < 26; i++) {
    scanf("%lld", &c[i]);
  }
  std::vector<std::vector<long long>> s(D, std::vector<long long>(26));
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      scanf("%lld", &s[i][j]);
    }
  }
  std::vector<long long> t(D);
  for (int i = 0; i < D; i++) {
    scanf("%lld", &t[i]);
  }
  long long M;
  scanf("%lld", &M);
  std::vector<long long> d(M);
  std::vector<long long> q(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &d[i]);
    scanf("%lld", &q[i]);
  }
  solve(D, std::move(c), std::move(s), std::move(t), M, std::move(d), std::move(q));
  return 0;
}

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

int main(void)
{
	long long a, b, c;
	int i;
	long long t = 0;
	int n = 0;
	cin >> a >> b >> c;

	for (i = 0; i <= b; i++) {
		t = a * i;

		if (t % b == c) {
			cout << "YES" << endl;
			n++;
			break;
		}
	}

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

Measured memory_bytes: 256
S = list(input())

S.sort()

flag = 1

if 'N' in S:
    if 'S' not in S:
        flag = 0

if 'S' in S:
    if 'N' not in S:
        flag = 0

if 'E' in S:
    if 'W' not in S:
        flag = 0

if 'W' in S:
    if 'E' not in S:
        flag = 0

if flag:
    print('Yes')

else:
    print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <deque>
using namespace std;
using P = pair<int,int>;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
ll gcd(ll a, ll b) {//最大公約数
    if(a<b){
        ll tmp = a;
        a = b;
        b = tmp; 
    }
    if (b==0) return a;
    else return gcd(b, a%b);
}
ll lcm(ll a, ll b) {//最小公倍数
    return a * b / gcd(a, b);
}

int main(){
    string s;
    cin >> s;
    if(s[2]==s[3]&&s[4]==s[5]){
        cout << "Yes" << endl;
        return 0;
    }else{
        cout << "No" << endl;
        return 0;
    }
    return 0;
}




Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
using namespace std;
 
int N;
long long A[101], B[101];
int op[101], bb, cc, dd;
 
long long bf(int n) {
  if(n == bb) {
    long long ans = 0;
    for(int i = bb; i < cc; i++) {
      if(op[i] == 0) {
//        vis[i] = 1, vis[i + i] = 1;
        ans += max(0LL, A[i] + (op[i + i] == 0 ? B[i + i] : 0));
      }
    }
    for(int i = cc; i < dd; i++) {
      if(op[i] == 0) {
//        vis[i] = 1;
        ans += B[i];
      }
    }
    for(int i = dd + 1; i <= N; i+=2) {
      if(op[i] == 0) {
//        vis[i] = 1;
        ans += B[i];
      }
    }
    return ans;
  }
  if(op[n]) {
    return bf(n + 1);
  }else {
    long long now = A[n] + bf(n + 1);
    for(int i = n + n; i <= N; i += n) {
      op[i]++;
    }
    now = max(now, bf(n + 1));
    for(int i = n + n; i <= N; i += n) {
      op[i]--;
    }
    return now;
  }
}
 
long long bf2(int n) {
  if(n + n > N) {
    long long ans = 0;
    for(int i = n; i <= N; i++) {
      if(op[i] == 0) ans += B[i];
    }
    return ans;
  }
  if(op[n]) {
    return bf2(n + 1);
  }else {
    long long now = A[n] + bf2(n + 1);
    for(int i = n + n; i <= N; i += n) {
      op[i]++;
    }
    now = max(now, bf2(n + 1));
    for(int i = n + n; i <= N; i += n) {
      op[i]--;
    }
    return now;
  }
}
 
 
int main() {
  scanf("%d", &N);
  bb = N / 3 + 1;
  cc = N / 2 + 1;
  dd = bb + bb;
  for(int i = 1; i <= N; i++) {
    scanf("%lld", &A[i]);
    if(A[i] > 0) B[i] = A[i];
  }
  if(N < 10) printf("%lld\n", max(0LL, A[1] + bf2(2)));
  else printf("%lld\n", max(0LL, A[1] + bf(2)));
//  for(int i = 1; i <= N; i++) if(!vis[i])cout << i << "\n";
}

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

int A[22][22];
ll dp[22][(1<<22)];

int main(){
  int N; cin>>N;
  rep(i,N) rep(j,N) cin>>A[i][j];
  dp[0][0]=1;
  rep(i,N) rep(bit,(1<<N)) if(dp[i][bit]){
    rep(j,N){
      if(!(bit&(1<<j))&&A[i][j]){
        (dp[i+1][bit+(1<<j)]+=dp[i][bit])%=MOD;
      }
    }
  }
  cout<<dp[N][(1<<N)-1]<<endl;
  return 0;
}


Measured memory_bytes: 321792
#include <bits/stdc++.h>
int n;
long long a, b;
using std::cin;
using std::cout;
#define For( i, j, k ) for( int i = j; i <= k; ++i )
int main( )
{
	std::ios::sync_with_stdio( false );
	cin >> n;
	a = 1, b = 1;
	long long T, F;
	For( i, 1, n )
	{
		cin >> T >> F;
		long long c, d;
		c = ( a - 1 ) / T + 1;
		d = ( b - 1 ) / F + 1;
		a = std::max( c, d ) * T;
		b = std::max( c, d ) * F;
	}
	cout << a + b;
	return 0;
}

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

using namespace std;
typedef long long ll;

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

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

  int a, b, c;
  cin >> a >> b >> c;
  swap(a, b);
  swap(a, c);

  cout << a << " " << b << " " << c << endl;

  return 0;
}


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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) rep2(i, 0, n)
#define rep1(i, n) rep1(i, 1, n + 1)

// #define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
// #define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()  //

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);
    //    cout << std::setfill('0') << std::setw(2);

    long long A;
    std::cin >> A;
    long long B;
    std::cin >> B;
    long long M;
    std::cin >> M;
    std::vector<long long> a(A);
    for (int i = 0; i < A; i++) {
        std::cin >> a[i];
    }
    std::vector<long long> b(B);
    for (int i = 0; i < B; i++) {
        std::cin >> b[i];
    }
    std::vector<long long> x(M);
    std::vector<long long> y(M);
    std::vector<long long> c(M);
    for (int i = 0; i < M; i++) {
        std::cin >> x[i];
        std::cin >> y[i];
        std::cin >> c[i];
    }

    ll minA = *min_element(all(a));
    ll minB = *min_element(all(b));
    ll ans = minA + minB;
    rep(i, M) {
        ll temp = a[--x[i]] + b[--y[i]] - c[i];
        ans = min(ans, temp);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4224
N = int(input())
A = []
for _ in range(2):
    A.append(list(map(int,input().split())))
dp = [[0]*N for _ in range(2)]
dp[0][0] = A[0][0]
dp[1][0] = dp[0][0] + A[1][0]
for i in range(1,N):
    dp[0][i] = dp[0][i-1] + A[0][i]

for i in range(1,N):
    dp[1][i] = A[1][i] + max(dp[0][i],dp[1][i-1])

print(dp[1][N-1])


Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

ll dp[110][5][2];

int main(){
  string s; cin >> s;
  int K; cin >> K;
  int n=s.size();
  dp[0][0][0]=1;
  rep(i,n)rep(j,4)rep(k,2){
    int nd=s[i]-'0';
    rep(d,10){
      int ni=i+1,nj=j,nk=k;
      if(k==0){
        if(d>nd) continue;
        if(d<nd) nk=1;
      }
      if(d) nj++;
      dp[ni][nj][nk]+=dp[i][j][k];
    }
  }
  cout << dp[n][K][0]+dp[n][K][1] << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def main():
    N,M = map(int,input().split())
    A = set([int(input()) for _ in range(M)])
    MOD = 1000000007
    ans = [1]
    ans.append(0) if 1 in A else ans.append(1)
    for i in range(2,N+1):
        ans.append(0)
        if i in A:
            continue
        ans[i] += (ans[i-1] + ans[i-2])
    print(ans[N] % MOD)
if __name__ == '__main__':
    main()

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

int main(void){
    int n = 0, k = 0; 

    scanf("%d%d", &n, &k);

    if(n % k == 0){
        printf("0\n");
    }else{
        printf("1\n");
    }

    return 0;

} 


Measured memory_bytes: 256
import bisect
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
sa = [0]*(n+1)
sb = [0]*(m+1)
for i in range(n):
    sa[i+1] = sa[i]+a[i]
for i in range(m):
    sb[i+1] = sb[i]+b[i]
ans = 0
for i in range(n+1):
    t = sa[i]
    s = i
    tl = k-t
    if tl < 0:
        continue
    s += bisect.bisect_right(sb, tl)-1
    ans = max(ans,s)
print(ans)

Measured memory_bytes: 110540
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>

#define p(a, b) pair<a, b>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int sx = 0 , sy = 0, st = 0;
    for (int i = 0;i < n;i++) {
        int t,x,y;
        cin >> t >> x >> y;
        int dist = abs(x-sx) + abs(y-sy);
        int aval = t - st;
        if(dist > aval){
            cout << "No";
            return 0;
        } else {
            int rest = aval - dist;
            if(rest%2){
                cout << "No";
                return 0;
            } else {
                sx = x;
                sy = y;
                st =t;
            }
        }
    }
    cout << "Yes";
    return 0;
}


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

int main(void){
		string number;
		while(1){
				cin >> number;
				int sum = 0;
				if(number == "0") break;
				for(int i = 0;i < number.size();i++){
						sum += number[i] - '0';
				}
				cout << sum <<endl;
		}
		return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>
#include <stack>
#include <vector>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <set>
#include <limits>
#include <numeric>
#include <array>
using namespace std;


int main()
{
	int a1, a2, a3;
	cin >> a1;
	cin >> a2;
	cin >> a3;

	if (a1 + a2 + a3 >= 22)
	{
		cout << "bust" << endl;
	}
	else
	{
		cout << "win" << endl;
	}

	return 0;
}

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

int main()
{
  ll a;
  double b;
  cin >> a >> b;
  ll ib = b * 100 + 0.5;
  a *= ib;
  a /= 100;
  printf("%lld\n", a);
  return 0;
}


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

int main() {
  int D;
  cin >> D;
  if (D == 25) {
    cout << "Christmas" << endl;
  } else if (D == 24) {
    cout << "Christmas Eve" << endl;
  } else if (D == 23) {
    cout << "Christmas Eve Eve" << endl;
  } else {
    cout << "Christmas Eve Eve Eve" << endl;
  }
}


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

int main() {
    int n, m;
    std::cin >> n >> m;

    int t1 = 1900*m;
    int t2 = 100*(n-m);
    int tsum = t1 + t2;

    // 2700 / 4 + 2*2700 *(3/16) * 3*2700 *(9/64)
    //公比　3/4  1 - 1/(2*2)
    // 一ずつ増える 

    std::cout << tsum * (int)(std::pow(2, m)) << std::endl;
}

Measured memory_bytes: 3932
a,b=map(int,input().split())
s=input()

if len(s)!=a+b+1:
  print("No")
  exit()

for i in range(len(s)):
  if i<a:
    if s[i] not in ["0","1","2","3","4","5","6","7","8","9"]:
      print("No")
      exit()
  elif i==a:
    if s[i] != "-":
      print("No")
      exit()
  elif i<a+b+1:    
    if s[i] not in ["0","1","2","3","4","5","6","7","8","9"]:
      print("No")
      exit()
print("Yes")
exit()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  vector<int> d(n+1,0);
  rep(i,n + 1){
    if(i == 0) continue;
    d[i] = d[i-1] + l[i-1];
  }
  int ans = 0;
  rep(i,n+1){
    if(d[i] <= x)ans++;
  }
  cout << ans << endl;
}
 

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    char a;
    REP(i,3){
        REP(j,3){
            cin >> a;
            if(i==j){
                cout << a;
            }
        }
    }
    return 0;
}

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

int main(){
    int a[3][3],n,b;
    bool flag=false;

    for(int i = 0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> a[i][j];
        }
    }

    cin >> n;

    for(int k=0;k<n;k++){
        cin >> b;
        for(int i = 0;i<3;i++){
            for(int j=0;j<3;j++){
                if(a[i][j]==b)a[i][j]=0;

            }
        }
    }

    for(int i=0;i<3;i++){
        if(a[i][0]==0&&a[i][1]==0&&a[i][2]==0)flag = true;
        if(a[0][i]==0&&a[1][i]==0&&a[2][i]==0)flag = true;
    }
    if(a[1][1]==0&&a[2][2]==0&&a[0][0]==0)flag = true;
    if(a[1][1]==0&&a[0][2]==0&&a[2][0]==0)flag = true;

    if(flag == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from collections import Counter

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

tmp = n // 2

tmp1 = []
tmp2 = []

for i in range(n):
    if i % 2 == 0:
        tmp1.append(v[i])
    else:
        tmp2.append(v[i])

tmp1 = Counter(tmp1).most_common(2)
tmp2 = Counter(tmp2).most_common(2)

ans = n

for i in range(len(tmp1)):
    for j in range(len(tmp2)):
        if tmp1[i][0] == tmp2[j][0]:
            continue
        else:
            ans = min(ans, n - tmp1[i][1] - tmp2[j][1])

if ans == n and len(Counter(v)) == 1:
    print(tmp)
else:
    print(ans)

Measured memory_bytes: 16100
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main()
{
    fastio();
    int n,k;cin>>n>>k;
    int h[n];
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    vector<int> dp(n,1e9);
    dp[0]=0; //dp[i]=
    for(int i=1;i<n;i++)
    {
       for(int j=0;j<k;j++)
       {
            if(i-j-1<0)
            {
                break;
            }       
            dp[i] = min(dp[i],dp[i-j-1]+abs(h[i]-h[i-j-1]));  
       }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}    

Measured memory_bytes: 1024
#include <stdio.h>

int like[200000];

int main(void)
{
    int n;
    int cnt;
    int i, j;

    scanf("%d", &n);
    for (i = 1; i <= n; i++) scanf("%d", like + i);
    cnt = 0;
    for (i = 1; i <= n; i++) if (like[like[i]] == i) cnt++;
    printf("%d\n", cnt / 2);

    return 0;
}


Measured memory_bytes: 512
#include <string>
#include <vector>
#include <iostream>
#include <cmath>
#include <climits>
#include <algorithm>
int main() {
	int x, y, z, k;
	std::cin >> x >> y >> z >> k;
	std::vector<long long int> a(x);
	std::vector<long long int> b(y);
	std::vector<long long int> c(z);
	for (auto& n : a) std::cin >> n;
	for (auto& n : b) std::cin >> n;
	for (auto& n : c) std::cin >> n;
	std::vector<long long int> ab;
	for (const auto& n : a) {
		for (const auto& m : b) ab.push_back(n + m);
	}
	std::sort(ab.begin(), ab.end());
	std::vector<int> cIndex(z, ab.size() - 1);
	for (auto rank = 0; rank < k; ++rank) {
		long long int tempMax = 0;
		int tempIndex = 0;
		for (auto i = 0; i < cIndex.size(); ++i) {
			if (cIndex[i] >= 0 && tempMax < c[i] + ab[cIndex[i]]) {
				tempMax = c[i] + ab[cIndex[i]];
				tempIndex = i;
			}
		}
		cIndex[tempIndex]--;
		std::cout << tempMax << std::endl;
	}
}

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

using namespace std;

#define dprint(Exp,...) if(Exp){fprintf(stderr, __VA_ARGS__);}
#define printe(...) fprintf(stderr, __VA_ARGS__);
#define PrtExp(_Exp)  cerr<< #_Exp <<" = "<< (_Exp)
#define PrtExpN(_Exp)  cerr<< #_Exp <<" = "<< (_Exp) <<"\n"

#define SINT(n) scanf("%d",&n)
#define SINT2(n,m) scanf("%d %d",&n,&m)
#define SINT3(n,m,o) scanf("%d %d %d",&n,&m,&o)
#define SINT4(n,m,o,p) scanf("%d %d %d %d",&n,&m,&o,&p)
#define SINT5(n,m,o,p,q) scanf("%d %d %d %d %d",&n,&m,&o,&p,&q)
#define SLL(n) scanf("%lld",&n)
#define SLL2(n,m) scanf("%lld %lld",&n,&m)
#define SLL3(n,m,o) scanf("%lld %lld %lld",&n,&m,&o)
#define SST(s) scanf("%s",s)
#define SCH(c) scanf("%c",&c)

#define GC() getchar()

#define PINT(n) printf("%d",(int)(n))
#define PINT2(n,m) printf("%d %d",(int)(n),(int)(m))
#define PINT3(n,m,l) printf("%d %d %d",(int)(n),(int)(m),(int)(l))
#define PLL(n) printf("%lld",(long long)(n))
#define PST(s) printf("%s",(s))
#define PCH(s) printf("%c",(s))

#define PINTN(n) printf("%d\n",(int)(n))
#define PINT2N(n,m) printf("%d %d\n",(int)(n),(int)(m))
#define PINT3N(n,m,l) printf("%d %d %d\n",(int)(n),(int)(m),(int)(l))
#define PLLN(n) printf("%lld\n",(long long)(n))
#define PSTN(s) printf("%s\n",(s))
#define PCHN(s) printf("%c\n",(s))

#define PSP() printf(" ")
#define PN() printf("\n")

#define PC(c) putchar(c)
#define CSP (' ')
#define SN ("\n")

#define rep(i,a) for(int i=0;i<a;i++)
#define reP(i,a) for(int i=0;i<=a;i++)
#define Rep(i,a) for(int i=a-1;i>=0;i--)
#define ReP(i,a) for(int i=a;i>=0;i--)

#define rEp(i,a) for(i=0;i<a;i++)
#define rEP(i,a) for(i=0;i<=a;i++)
#define REp(i,a) for(i=a-1;i>=0;i--)
#define REP(i,a) for(i=a;i>=0;i--)

#define repft(i,a,b) for(int i=a;i<b;i++)
#define repfT(i,a,b) for(int i=a;i<=b;i++)
#define Repft(i,a,b) for(int i=a-1;i>=b;i--)
#define RepfT(i,a,b) for(int i=a;i>=b;i--)

#define foreach(a,it) for(auto it = a.begin(); it != a.end(); ++it)

#define FILL(a,v) fill(begin(a),end(a), v)
#define FILL0(a) memset(a,0,sizeof(a))
#define FILL1(a) memset(a,-1,sizeof(a))

typedef long long ll;

typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll>   Pll;


const int INF = 0x2aaaaaaa; // 715,827,882
const ll INFLL = 0x1f1f1f1f1f1f1f1fLL;//2,242,545,357,980,376,863

template <class A, class B> inline ostream& operator<<(ostream& st, const pair<A, B>& P) { return st << "(" << P.first << "," << P.second << ")"; };
template <class A, class B> inline pair<A, B> operator+(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first + Q.first, P.second + Q.second); };
template <class A, class B> inline pair<A, B> operator-(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first - Q.first, P.second - Q.second); };

#define fs  first
#define sc  second


int main() {
	int a, b, c, d, e;
	string s, t, u;

	cin >> a >> b >>s;
	bool f = true;

	if (s[a] != '-')f = false;

	rep(i, a) if (s[i] < '0' || '9' < s[i]) f = false;
	rep(i, b) if (s[a+1+i] < '0' || '9' < s[a + 1 + i]) f = false;

	cout << (f ? "Yes" : "No") << endl;

	//for (;;) getchar();

	return 0;
}

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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }

typedef long long ll;



int main() {
    vector<string> v(7);
    v[0]="SUN";
    v[1]="MON";
    v[2]="TUE";
    v[3]="WED";
    v[4]="THU";
    v[5]="FRI";
    v[6]="SAT";

    string s;
    cin >> s;
    auto a = find(ALL(v),s);
    auto i = distance(v.begin(),a);
    cout << 7-i << endl;

    return 0;
}


Measured memory_bytes: 256