akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

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

const long long MOD = 998244353;


vector<int> r, g, b;
map<int, int> dp[1 << 20];

int dfs(int bit, int c) {
    if (c < 0) return 0;

    if (bit == 0) {
        assert(c == 0);
        return c == 0;
    }
    if (dp[bit].count(c)) return dp[bit][c];

    int ans = 0;
    for (auto i : r) {
        if (bit >> i & 1) {
            for (auto j : g) {
                if (bit >> j & 1) {
                    for (auto k : b) {
                        if (bit >> k & 1) {
                            ans += dfs(bit - (1 << i) - (1 << j) - (1 << k), c - (max({i, j, k}) - min({i, j, k})));
                        }
                    }
                }

            }
        }
    }

    return dp[bit][c] = ans;
}


void solve(long long N, std::string S) {


    for (int i = 0; i < 3 * N; i++) {
        if (S[i] == 'R') { r.push_back(i); }
        if (S[i] == 'G') { g.push_back(i); }
        if (S[i] == 'B') { b.push_back(i); }

    }
    vector<int> C[3] = {r, g, b};
    auto H = [&](vector<int> &down, vector<int> &up, int d1, int mid, int d2) {
        ll d = upper_bound(down.begin(), down.end(), mid) - lower_bound(down.begin(), down.end(), d1);
        ll u = upper_bound(up.begin(), up.end(), d2) - lower_bound(up.begin(), up.end(), mid);
        return d * u % MOD;
    };

    ll mult = 1;
    for (int i = 0; i < N; i++) {
        pair<int, int> t[3] = {{r[i], 0},
                               {g[i], 1},
                               {b[i], 2}};
        sort(t, t + 3);
        ll v = H(C[t[0].second], C[t[2].second], t[0].first, t[1].first, t[2].first);
        mult *= v;
        mult %= MOD;
    }
    for(int i = 1 ; i <= N ; i++)
        mult *= i, mult %= MOD;
    cout << mult << endl;

}

int main() {
    long long N;
    scanf("%lld", &N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 52480
N= int(input())
now=0
ans=1
S=0
l=list(map(int,input().split()))
for i in range(1,N):
   X=l[i]-l[i-1]
   X=0 if X==0 else 1 if X>0 else -1
   if X==0:
      continue
   elif S ==0:
      S=X
   elif S != X:
      ans+=1
      S=0
print(ans)

Measured memory_bytes: 14480
// abc161_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    int sm = accumulate(ALL(A), 0);

    int cnt = 0;
    REP(i, N){
        if (A[i] * 4 * M >= sm){
            cnt++;
        }
    }
    if (cnt >= M){
        print("Yes");
    } else {
        print("No");
    }

    return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N, W; cin >> N >> W;
  vector<int> v(N), w(N); REP(i, N) cin >> v[i] >> w[i];
  int dp[110][10010];
  for(int i = 0; i < N; ++i) {
    for(int k = 0; k <= W; ++k) {
      if(k - w[i] >= 0) {
        chmax(dp[i + 1][k], dp[i][k - w[i]] + v[i]);
        chmax(dp[i + 1][k], dp[i + 1][k - w[i]] + v[i]);
      }
      chmax(dp[i + 1][k], dp[i][k]);
    }
  }
  cout << dp[N][W] << endl;
}


Measured memory_bytes: 7032
#include<bits/stdc++.h>
using namespace std;
int n;
int l=1;
 
set<int> st;
 
int main(){
  scanf("%d",&n);
  while(n--){
    int x;
    scanf("%d",&x);
    if(st.count(0)>0){
      printf("No\n");
      continue;
    }
     
    while(st.count(l)>0)l++;
 
    if(x<l-1 || (x==l-1 && (int)st.size()>l-1 ) ){
      printf("No\n");
      continue;
    }
 
    printf("Yes\n");
    while(st.count(x)>0){
      st.erase(x);
      x--;
    }
    st.insert(x);
  }
  return 0;
}

Measured memory_bytes: 14840
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int N, W; cin >> N >> W;
	vi v(N);
	vi w(N);
	REP(i,N) cin >> v[i] >> w[i];
	vvi dp(N + 1, vi(W + 1));
	FOR(i, 0, N) {
		REP(j, W + 1) {
			if (j < w[i]) {
				dp[i + 1][j] = dp[i][j];
			} else {
				dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
			}
		}
	}
	cout << dp[N][W] << endl;
}

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



Measured memory_bytes: 6744
#include<iostream>
#include<queue>
#include<string>
using namespace std;
 
int main()
{
    int i,n,q,x,sumq=0;
    string ss;
    queue<string> qt1;
    queue<int> qt2;
 
    cin >> n >> q;
 
    for(i=0;i<n;i++){
        cin >> ss >> x ;
        qt1.push(ss);
        qt2.push(x);
    }
 
    while(!qt1.empty()){
        if((qt2.front() - q) > 0 ){
            x = qt2.front() - q;
            qt2.pop();
            qt2.push(x) ;
            ss = qt1.front();
            qt1.pop();
            qt1.push(ss);
            sumq = sumq + q;
        }
        if((qt2.front()-q) <= 0){
            sumq = sumq + qt2.front();
            cout << qt1.front() << ' ' << sumq <<endl ;
            qt1.pop();
            qt2.pop();
        }
    }
 
    return 0;
}

Measured memory_bytes: 4176
#include <stdio.h>

int main(void){

	int N=0,M=0,sum=0,i=0,day=0;
	  
	scanf("%d",&N);
  	scanf("%d",&M);
  	
  	int A[M];
  	for(i=0;i<M;i++){
   		scanf("%d",&A[i]);
    	sum=sum+A[i];
    }
  	
  	day=N-sum;
  	if(day<0){
    	printf("-1");
    }else if(day>=0){
    	printf("%d",day);
    }
  
  	return 0;
  
}


Measured memory_bytes: 2136
#include<bits/stdc++.h>
using namespace std;
const int N=55;
int n,a[N],mn,mx;
queue<pair<int,int> >q;
int main()
{
    scanf("%d",&n);
    int p1=0,p2=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]),mn=min(mn,a[i]),mx=max(mx,a[i]);
        if(a[i]<=mn) mn=a[i],p1=i;
        if(a[i]>=mx) mx=a[i],p2=i;
    }
    if(abs(mn)>abs(mx))
    {
        for(int i=1;i<=n;i++)
            if(a[i]>0)
            {
                a[i]+=mn;
                q.push({p1,i});
            }
        for(int i=n-1;i>=1;i--)
            q.push({i+1,i}),a[i]+=a[i+1];
    }
    else
    {
        for(int i=1;i<=n;i++)
            if(a[i]<0)
        {
            a[i]+=mx;
            q.push({p2,i});
        }
        for(int i=2;i<=n;i++)
            q.push({i-1,i}),a[i]+=a[i-1];
    }
    printf("%d\n",q.size());
    while(!q.empty())
        printf("%d %d\n",q.front().first,q.front().second),q.pop();
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  for(int n;cin>>n&&n;){
    int w,h,w0,h0,xy[200][200]={},r=0;
  cin>>w>>h;
  for(int i=0,a,b;i<n&&cin>>a>>b;i++) xy[b-1][a-1]=1;
  cin>>w0>>h0;
  for(int i=0;i<h-h0+1;i++) for(int j=0;j<w-w0+1;j++){
      int r0=0;
      for(int k=0;k<h0;k++) for(int l=0;l<w0;l++) r0+=xy[i+k][j+l];
      r=max(r,r0);
    }
  cout<<r<<endl;
  }
  return 0;
}

Measured memory_bytes: 3204
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

void solve(){
  int a, b, c, d; cin >> a >> b >> c >> d;
  int cnt = 0;
  while(a > 0 && c > 0){
    if(cnt % 2 == 0) c -= b;
    else a -= d;
    cnt++;
  }
  if(cnt % 2 == 1) cout << "Yes" << endl;
  else cout << "No" << endl;
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main {

	private static int[] a;
	private static boolean[] visited;
	private static List<Integer>[] g;
	private static Map<Integer, Map<Integer, Integer>> ws;


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		g = new ArrayList[n];
		ws = new HashMap<>();

		for (int i = 0; i < g.length; i++) {
			g[i] = new ArrayList<>();
			ws.put(i, new HashMap<>());
		}

		//ws = new int[n][n];
		//for (int i = 0; i < ws.length; i++) {
		//	Arrays.fill(ws[i], Integer.MAX_VALUE);
		//}


		for (int i = 0; i < n - 1; i++) {
			int u = sc.nextInt() - 1;
			int v = sc.nextInt() - 1;
			int w = sc.nextInt() % 2;
			g[u].add(v);
			g[v].add(u);
			ws.get(u).put(v, w);
			ws.get(v).put(u, w);
			//ws[u][v] = w;
			//ws[v][u] = w;
		}

		a = new int[n];
		visited = new boolean[n];

		dfs(0, 0);
		for (int i : a) System.out.println(i);

		//int[] a = new int[n];
		//boolean[] visited = new boolean[n];
		//Queue<Integer> q = new LinkedList<>();
		//Queue<Integer> r = new LinkedList<>();
		//q.offer(0);
		//
		//while (!q.isEmpty()) {
		//	while (!q.isEmpty()) {
		//		int p = q.poll();
		//		if (visited[p]) continue;
		//		visited[p] = true;
		//		a[p] = 0;
		//
		//		for (Integer x : g[p]) {
		//			if (!visited[x]) {
		//				if (ws[p][x] == 0) {
		//					q.offer(x);
		//				} else {
		//					r.offer(x);
		//				}
		//			}
		//		}
		//	}
		//
		//	while (!r.isEmpty()) {
		//		int p = r.poll();
		//		if (visited[p]) continue;
		//		visited[p] = true;
		//		a[p] = 1;
		//
		//		for (Integer x : g[p]) {
		//			if (!visited[x]) {
		//				if (ws[p][x] == 0) {
		//					r.offer(x);
		//				} else {
		//					q.offer(x);
		//				}
		//			}
		//		}
		//	}
		//}

		//for (int i : a) {
		//	System.out.println(i);
		//}
	}

	private static void dfs(int v, int c) {
		if (visited[v]) return;
		visited[v] = true;
		a[v] = c;
		for (int i = 0; i < g[v].size(); i++) {
			int x = g[v].get(i);
			if (visited[x]) continue;
			if (ws.get(v).get(x) == 0) dfs(x, c);
			else dfs(x, c == 0 ? 1 : 0);
		}
	}
}


Measured memory_bytes: 138148
#include <bits/stdc++.h>
using namespace std;
int n,k,x,y,ans;
int main() {
	scanf("%d %d %d %d",&n,&k,&x,&y);
	if (n<=k)
		ans=n*x;
	else ans=k*x+(n-k)*y;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.regex.*;
import java.math.*;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		//int a = sc.nextInt();
		// スペース区切りの整数の入力
		//int b = sc.nextInt();
		//int c = sc.nextInt();
		// 文字列の入力
		//String s = sc.next();
		//1文字ずつ
		//s.atChar(i);
		// 出力
		//System.out.println("");
		//double countx=0;
		int n=sc.nextInt();
		
		System.out.println(1110-n);
		
	}
}

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

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

    for(int i = 0; i < n-k; i++) {
        if(a[i] < a[i+k]){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4048
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 10 ;
int n , m ;
string s[N] ;

void err () {
	cout << "Impossible\n" ;
	exit(0) ;
}

void go (int x , int y) {
	s[x][y] = '.' ;

	if (x == n - 1 && y == m - 1) return ;

	if (x == n - 1) {
		if (s[x][y + 1] != '#') err() ;
		go(x , y + 1) ;
	}
	else if (y == m - 1) {
		if (s[x + 1][y] != '#') err() ;
		go(x + 1 , y) ;
	}
	else {
		if (s[x + 1][y] == '#') go(x + 1 , y) ;
		else if (s[x][y + 1] == '#') go(x , y + 1) ;
		else err() ;
	}
}

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

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

	go(0 , 0) ;

	for (int i = 0 ; i < n ; i ++)
		for (int j = 0 ; j < m ; j ++)
			if (s[i][j] == '#') err() ;

	cout << "Possible\n" ;
}

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

n, m = map(int, input().split())
x = list(map(int, input().split()))

x.sort()

d = [x[i] - x[i-1] for i in range(1,m)]

d.sort()

if n >= m:
    print(0)
else:
    ans = sum(d[:m-n])
    print(ans)


Measured memory_bytes: 13188
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0;
#define HERE cout<<"here"<<en

#define MOD 100000
#define yoko 1
#define tate 0

struct direction{
  int ordi_up,ordi_right;
  int just_turned_right,just_turned_up;
};

int main(){
  int h,w;
  while(cin>>h>>w&&w&&h){
    direction d[105][105];
    for(int i=1; i<=h; i++) for(int j=1; j<=w; j++){
      d[i][j].ordi_up=0; d[i][j].ordi_right=0;
      d[i][j].just_turned_up=0; d[i][j].just_turned_right=0;
    }
    
    for(int i=1; i<=h; i++){
      for(int j=1; j<=w; j++){
        if(i==1||j==1){
          if(i>j) d[i][j].ordi_up=1;
          else d[i][j].ordi_right=1;
          continue;
        }
        if(i==2||j==2){
          if(i>j) {d[i][j].ordi_up=1; d[i][j].just_turned_right=1;}
          else if(i<j){ d[i][j].just_turned_up=1; d[i][j].ordi_right=1;}
          else d[i][j].just_turned_right=d[i][j].just_turned_up=1;
          continue;
        }
        d[i][j].ordi_right=(d[i][j-1].ordi_right+d[i][j-1].just_turned_right)%MOD;
        d[i][j].ordi_up=(d[i-1][j].ordi_up+d[i-1][j].just_turned_up)%MOD;
        d[i][j].just_turned_right=d[i][j-1].ordi_up%MOD;
        d[i][j].just_turned_up=d[i-1][j].ordi_right%MOD;
      }
    }
    
    int ans=(d[h][w].ordi_right+d[h][w].ordi_up+d[h][w].just_turned_right+d[h][w].just_turned_up)%MOD;
    cout<<ans<<en
  }
}



Measured memory_bytes: 3208
class UnionFind():
  def __init__(self, n):
    self.n=n
    self.parents=[-1]*n

  def find(self,x):
    if self.parents[x]<0:
      return x
    else:
      self.parents[x]=self.find(self.parents[x])
      return self.parents[x]

  def unite(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if x == y:
      return
    if self.parents[x]>self.parents[y]:
      x,y=y,x
    self.parents[x]+=self.parents[y]
    self.parents[y]=x

  def size(self, x):
    return -self.parents[self.find(x)]

  def same(self, x, y):
    return self.find(x) == self.find(y)

  def roots(self):
    return [i for i,x in enumerate(self.parents) if x<0]

N,M=map(int,input().split())
uf=UnionFind(N)
for _ in range(M):
  a,b=map(int,input().split())
  uf.unite(a-1,b-1)
ans=0
for r in uf.roots():
  s=uf.size(r)
  ans=max(ans,s)
print(ans)

Measured memory_bytes: 18388
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int A, B, C, K; cin >> A >> B >> C >> K;
	int ans = 0;
	ans += min(A, K);
	K -= A + B;
	if (K > 0) {
		ans += -1 * min(C, K);
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3652
//Dragon_warrior7(IITK)
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define umap unordered_map
#define uset unordered_set
#define ll long long
#define lll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define ull unsigned ll
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define fo(i,a,b) for(int i=a;i<b;i++)
#define Lets_be_precise cout<<fixed<<setprecision(10)
//typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
// const int mod=1e9+7;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=100000+11;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
	cin>>v[i];
}
#define cerr if(false)cerr//uncomment to remove cerr from program...
void solveforthiscase(const int & test)
{//deb(test);
string s;
cin>>s;
if(s[2]==s[3] && s[4]==s[5])
cout<<"Yes";
else
cout<<"No";









return ;
}

int main()
{
	ios_base::sync_with_stdio(false);
	Lets_be_precise;
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

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

using ll = long long;

#define FOR(i,a,n) for(int i = (a); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

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

int tiles[2001][2001];
void vote(int x, int y, int x2, int y2) {
  tiles[x][y]++;
  tiles[x2][y]--;
  tiles[x][y2]--;
  tiles[x2][y2]++;
}

int main() {
  int n, k; cin >> n >> k;
  int x, y; char c;
  REP(i,n) {
    cin >> x >> y >> c;
    if (c == 'W') y += k;
    x %= 2*k; y %= 2*k;

    if ((x < k && y < k) || (x >= k && y >= k)) {
      x %= k; y %= k;
      vote(0, 0, x+1, y+1);
      vote(x+k+1, 0, 2*k, y+1);
      vote(0, y+k+1, x+1, 2*k);
      vote(x+k+1, y+k+1, 2*k, 2*k);
      vote(x+1, y+1, x+k+1, y+k+1);
    } else {
      x %= k; y %= k;
      vote(x+1, 0, x+k+1, y+1);
      vote(0, y+1, x+1, y+k+1);
      vote(x+1, y+k+1, x+k+1, 2*k);
      vote(x+k+1, y+1, 2*k, y+k+1);
      }
    }

    FOR(i,0,2*k+1) FOR(j,1,2*k+1) tiles[i][j] += tiles[i][j-1];
    FOR(i,1,2*k+1) FOR(j,0,2*k+1) tiles[i][j] += tiles[i-1][j];
  int ans = 0;
  REP(i,2*k+1) REP(j,2*k+1) chmax(ans, tiles[i][j]);
  cout << ans << endl;
}

Measured memory_bytes: 15872
#include <iostream>

using namespace std;

int main(void) {

	int N;
	cin >> N;

	// [0]=2, [1]=1
	unsigned long long pre[2] = { 2, 1 };

	unsigned long long v = 0;
	if (N == 1) {
		v = pre[1];
	} else {
		for (int i = 2; i <= N; i++) {
			v = pre[0] + pre[1];
			pre[0] = pre[1];
			pre[1] = v;
		}
	}

	cout << v << endl;

	return 0;
}


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

int main()
{
	int n, a, b;
	string s;
	cin >> n >> a >> b >> s;
	int total = a + b;
	for (int i = 0; i < n; i++)
	{
		if (total <= 0 || s[i] == 'c')
		{
			cout << "No" << '\n';
		}
		else if (s[i] == 'a')
		{
			cout << "Yes" << '\n';
			total--;
		}
		else
		{
			if (b > 0)
			{
				cout << "Yes" << '\n';
				b--;
				total--;
			}
			else
			{
				cout << "No" << '\n';
			}
		}
	}
	return (0);
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
int main(){
	int h, w, k, total=0;
	cin >> h >> w >> k;
	char grid[h+1][w+1];
	for(int i=0; i<h; ++i){
		for(int j=0; j<w; ++j){
			cin >> grid[i][j];
		}
	}
	for(int i=0; i<=(1<<h)-1; ++i){
		for(int j=0; j<=(1<<w)-1; ++j){
			int b=0;
			//cout << i << " " << j << endl;
			for(int m=0; m<h; ++m){
				for(int l=0; l<w; ++l){
					//cout << ((i>>m)&1) << " " << ((j>>l)&1) << " " << grid[m][l] << endl;
					if(((i>>m)&1)==0 && ((j>>l)&1)==0 && grid[m][l] == '#'){
						b++;
					}
				}
			}
			//cout << b << endl;
			if(b==k){
				total++;
			}
		}
	}
	cout << total;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  string S;
  cin >> S;
  for (int len = S.size() - 2; len >= 0; len -= 2) {
    string sub = S.substr(0, len);
    string l = S.substr(0, len / 2);
    string r = S.substr(len / 2, len / 2);
    if (l == r) {
      cout << len << endl;
      return 0;
    }
  }
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	vector<int> a(n);
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	
	int i = a[0];
	int cnt = 0;
	while(++cnt != n)
	{
		if(i == 2)
		{
			cout << cnt << endl;
			return 0;
		}
		
		int dx = i - 1;
		i = a[dx];
	}
	cout << -1 << endl;
	
	return 0;
}

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

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

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

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll B[105];
bool U[105];

int main()
{
    int N;
    cin >> N;
    REP(i, N)
    {
        cin >> B[i];
    }
    bool c = true;
    REP(i, N)
    {
        if (B[i] > i + 1)
            c = false;
    }
    if (!c)
    {
        cout << -1 << endl;
        return 0;
    }

    vector<int> v;
    //! 後ろの要素から入れていく
    REP(i, N)
    {
        for (int j = N - 1; j >= 0; --j)
        {
            if (U[j] || B[j] > i + 1)
                continue;
            //! B[j]を入れたい
            bool c = true;
            FOR(k, N, j + 1)
            {
                if (B[j] > B[k] && !U[k])
                {
                    c = false;
                    break;
                }
            }
            int n = 0;
            REP(k, j)
            {
                if (U[k])
                    n++;
            }
            if (!c || n < B[j] - 1)
                continue;
            v.push_back(B[j]);
            U[j] = true;
            break;
        }
    }

    REP(i, v.size())
    {
        cout << v[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   int  n ;
   cin >> n ;
   long long int t[n] , sum2 = 0 ;
   int  m  ;

   for (int i = 1 ; i <= n ; i++){
    cin >> t[i] ;
    sum2 += t[i];
   }
   cin >> m ;
   int sum[m];
   int p [m] , X[m] ;
   for (int i = 1 ; i <= m ; i++){
    cin >> p[i] ;
    cin >> X[i];
    //sum2 += x[i] ;
   }
//cout << sum2 << endl ;
   for (int i = 1 ; i <= m ; i++){

      sum[i] = sum2 - t[p[i]] + X[i] ;
//     cout << t[p[i]] << endl   ;
//     cout << X[p[i]] << endl ;
      cout << sum[i] << endl;
   }


 return 0 ;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
 int x, a, y, i, count = 0;
 scanf("%d%d%d", &x, &y, &a);
 for(i = 1; i <= a; i++) {
  if(0 == (a % i)) {
   if(x <= (a / i) && (a / i) <= y) {
    count++;
   }
  }
 }
 printf("%d\n", count);
 return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int n,W;
long long int dp[101][100005];
long long int w[100005],v[100005];
long long int count(int i,int j)
{
	if(i==n)
	return 0;
	if(j==W)
	return 0;
	if(dp[i][j]!=-1)
	return dp[i][j];
	if(j+w[i]>W)
	return dp[i][j]=count(i+1,j);
	else
	return dp[i][j]=max((v[i]+count(i+1,j+w[i])),count(i+1,j));
}  
int main()
{
	for(int i=0;i<101;i++)
	{
		for(int j=0;j<100005;j++)
		dp[i][j]=-1;
	}
	cin>>n>>W;
	for(int i=0;i<n;i++)
	cin>>w[i]>>v[i];
	cout<<count(0,0);
}

Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int N,M;
	while(true){
		scanf("%d%d",&N,&M);
		if(N==0&&M==0)return 0;
		int seats[10009];
		for(int i=0;i<10009;i++){
			seats[i]=0;
		}
		
		for(int i=0;i<M;i++){
			string S;
			cin >> S;
			if(S=="A"){
				for(int j=0;j<N;j++){
					if(seats[j]==0){
						seats[j]=1;
						break;
					}
				}
			}
			else if(S=="B"){
				bool F=true;
				for(int j=N-1;j>=0;j--){
					if(F&&(j==0||seats[j-1]!=1)&&(j==N-1||seats[j+1]!=1)&&seats[j]==0){
						seats[j]=2;F=false;
					}
				}
				if(F){
					for(int j=0;j<N;j++){
						if(seats[j]==0){
							seats[j]=2;
							break;
						}
					}
				}
			}
			else if(S=="C"){
				bool F=true;bool FF=true;
				for(int j=0;j<N;j++){
					if(seats[j]!=0){
						FF=false;
					}
				}
				if(FF){
					seats[N/2]=3;
					F=false;
				}
				if(!F)continue;
				for(int j=0;j<N;j++){
					if(seats[j]!=0){
						if(F&&j!=N-1&&seats[j+1]==0){
							seats[j+1]=3;F=false;
						}
						else if(F&&j!=0&&seats[j-1]==0){
							seats[j-1]=3;F=false;
						}
					}
				}
			}
			else{
				int maxd=-1,maxi;
				bool F=true;
				for(int i=0;i<N;i++){
					if(seats[i]!=0)F=false;
				}
				if(F){
					seats[0]=4;
					continue;
				}
				for(int i=0;i<N;i++){
					int d=0;
					if(seats[i]!=0)d=-114;
					int l=i;int r=i;
					while((l<0||seats[l]==0)&&(r>=N||seats[r]==0)){
						d++;l--;r++;
					}
					if(maxd<d){
						maxd=d;
						maxi=i;
					}
				}
				seats[maxi]=4;
			}
			
		}
		for(int i=0;i<N;i++){
				if(seats[i]==0)printf("#");
				if(seats[i]==1)printf("A");
				if(seats[i]==2)printf("B");
				if(seats[i]==3)printf("C");
				if(seats[i]==4)printf("D");
			}
			printf("\n");
	}
}

Measured memory_bytes: 1236
# cf16-finalC - Interpretation
class UnionFind:  # O(α(N))
    def __init__(self, size):  # construct a Union-Find tree (1-idx)
        self.parent = [i for i in range(size + 1)]
        self.rank = [0] * (size + 1)

    def find(self, x):  # find the group (root) of a vertex
        if self.parent[x] == x:
            return x
        self.parent[x] = self.find(self.parent[x])
        return self.parent[x]

    def is_same(self, x, y):  # check two vertices are in the same group
        return self.find(x) == self.find(y)

    def unite(self, x, y):  # unite two groups
        x, y = self.find(x), self.find(y)
        if x == y:  # in the same group
            return
        # unite a small one to a bigger one to balance trees
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1


def main():
    N, M = map(int, input().split())
    A = tuple(tuple(map(int, input().split())) for _ in range(N))
    uf, spoken = UnionFind(M), set()
    for _, *langs in A:
        spoken.update(langs)
        primary = langs[0]
        for l in langs[1:]:
            uf.unite(primary, l)
    cur = uf.find(spoken.pop())
    flg = all(uf.find(lang) == cur for lang in spoken)
    print("YES" if flg else "NO")


if __name__ == "__main__":
    main()

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

int main() {
  int N;
  cin>>N;
  int sum=0;
  for(int i=0;i<N;i++){
    int a,b;
    cin>>a>>b;
    sum+=b-a+1;
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int q,a,b,c,d,l,r,m,i;
inline int cel(int a,int b){return (a+b-1)/b;}
inline void F0(int a,int b,int c,int d){
	int x;
	x=a/b;
	for(i=c;i<=d;++i)putchar((i-1)%(x+1)==x?'B':'A');
}
inline void F11(int a,int b,int dd,int c,int d){
	for(l=1,r=a;l<r;){
		m=l+r>>1;
		if(cel(b,m)<=dd && cel(a,m)<=dd)r=m;else l=m+1;
	}
	int bb=b-(l-1)*dd,lm=a-l+1+bb;
	for(i=c;i<=d;++i)if(i<=lm)putchar(i<=a-l+1?'A':'B');
		else putchar((i-lm-1)%(1+dd)==0?'A':'B');
}
inline void F1(int a,int b,int dd,int c,int d){
	for(l=0,r=a/dd;l<r;){
		m=l+r+1>>1;
		if(cel(b,a-m*dd+m)<=dd)l=m;else r=m-1;
	}
	if(!l)return F11(a,b,dd,c,d);
	int x=b-dd*(a-l*dd+l-1),lm1=dd+x,lm2=dd*l+x+dd*(l-1);
	for(i=c;i<=d && i<=lm2;++i)if(i<=lm1)putchar(i<=dd?'A':'B');
		else putchar((i-lm1-1)%(dd*2)<dd?'A':'B');
	if(d>lm2)F11(a-dd*l,b-x-dd*(l-1),dd,max(1,c-lm2),d-lm2);
}
inline void F2(int a,int b,int x,int c,int d){
	for(l=0,r=a/x;l<r;){
		m=l+r+1>>1;
		if((a>m*x && cel(b-m,a-m*x)<=x) || (a==m*x && b<=m))l=m;else r=m-1;
	}
	int y=l*(x+1);
	if(c<=y)F0(l*x,l,c,min(d,y));
	if(d>y)F1(a-l*x,b-l,x,max(c-y,1),d-y);
}
inline void F3(int a,int b,int c,int d){
	for(l=0,r=b;l<r;){
		m=l+r>>1;
		if(cel(b,a+1)>=cel(b-m,a))r=m;else l=m+1;
	}
	if(c<=l)for(i=c;i<=l && i<=d;++i)putchar('B');
	if(d>l)F2(a,b-l,cel(b,a+1),max(c-l,1),d-l);
}
int main(){
//	freopen("1","r",stdin);
	scanf("%d",&q);
	for(;q--;){
		scanf("%d%d%d%d",&a,&b,&c,&d);
		if(a==b)F0(a,b,c,d);else if(a>=b)F2(a,b,cel(a,b+1),c,d);else F3(a,b,c,d);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
using namespace std;

int N,K;
int b[2002][2002];
int s[4002][4002];
 
int get(int x , int y){
	return s[x+K-1][y+K-1] + s[x-1][y-1] - s[x-1][y+K-1] - s[x+K-1][y-1];
}
 
int main(){
	cin >> N >> K;
	repp(i,0,N){
		int x,y;
		char c;
		cin >> x >> y >> c;
		if(c=='W') y += K;
		++b[x%(2*K)+1][y%(2*K)+1];
	}
	repp(i,1,4*K+1){
		repp(j,1,4*K+1){
			s[i][j] = s[i][j-1] + b[(i-1)%(2*K)+1][(j-1)%(2*K)+1];
		}
	}
	repp(j,1,4*K+1){
		repp(i,1,4*K+1){
			s[i][j] += s[i-1][j];
		}
	}
	int ans = 0;
	repp(i,1,2*K+1){
		repp(j,1,2*K+1){
			ans = max(ans , get(i,j) + get(i+K,j+K));
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 78464
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;
#define lint long long
static const int INF = 1 << 22;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
/*******source code below********/
int main(void) {

	int n; cin >> n;
	string S; cin >> S;
	long long L; cin >> L;

	char a = S[L - 1];
	for (lint i = 0; i < S.size(); i++)
	{
		if (S.at(i) != a) S.at(i) = '*';
	}
	cout << S << 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;
typedef pair<int,int>P;

vector<P>E[100000];
int d[100000],b[100000],cnt[200001],u[200000],v[200000],r[200000];
int main(){
	int n,m,q;scanf("%d%d%d",&n,&m,&q);
	rep(i,m){
		scanf("%d%d",&u[i],&v[i]);u[i]--;v[i]--;r[i]=q;
	}
	rep(i,q){
		int a;scanf("%d",&a);r[a-1]=i;
	}
	rep(i,m){
		E[u[i]].push_back(P(v[i],r[i]));E[v[i]].push_back(P(u[i],r[i]));
	}
	d[0]=1;b[0]=q;
	queue<int>que;que.push(0);
	while(!que.empty()){
		int p=que.front();que.pop();
		for(auto&v:E[p]){
			if(d[v.first]==0){
				d[v.first]=d[p]+1;que.push(v.first);
			}
			if(d[v.first]==d[p]+1)
				b[v.first]=max(b[v.first],min(b[p],v.second));
		}
	}
	rep(i,n)cnt[b[i]]++;
	int ans=0;
	rep(i,q){
		ans+=cnt[i];
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 15504
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define PI 3.141592653589793
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const ll INF = 1LL << 60;

//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main() {
    ll n,x,t;
    cin >> n >> x >> t;
    ll ans=t*(n/x);
    if (n%x){
        ans+=t;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  
  if(a==1&&b==1){
    cout << "Draw" << endl;
  }
  
  else if(a==1){
    cout << "Alice" << endl;
  }
  
  else if(b==1){
    cout << "Bob" << endl;
  }

  else if(a>b){
    cout << "Alice" << endl;
  }

  else if(a<b){
    cout << "Bob" << endl;
  }
  
  else if(a==b){
    cout << "Draw" << endl;
  }
}
  

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

int main() {
  string S;
  cin >> S;
  int L;
  L = S.size();
  int n0 = 0;
  int n1 = 0;
  for (int i=0; i<L; i++) {
    if (S[i] == '0') {
      n0++;
    }
    else {
      n1++;
    }
  }
  cout << min(n0,n1) * 2 << endl;
}

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

int main(void){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a-c>d||c-a>d){
    if((a-b>d||b-a>d)||(c-b>d||b-c>d))cout<<"No";
    else cout<<"Yes";
  }
  else cout<<"Yes";
  return 0;
}


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

int main(){
  int K;
  string S;
  cin >> K >> S;

  if(K >= S.size()){
    cout << S << endl;
  }
  else{
    for(int i=0; i<K; i++){
      cout << S[i];
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

bool isOK(int number){

	bool FLG = true;
	int pre = number%10,current;

	number /= 10;

	while(number != 0){
		current = number%10;
		if(current != pre-1){
			FLG = false;
			break;
		}
		number /= 10;
		pre = current;
	}

	return FLG;
}

int main(){

	int N,tmp;
	scanf("%d",&N);
	int table[N];

	for(int i = 0; i < N; i++){
		scanf("%d",&table[i]);
	}

	int maximum = -1;

	for(int i = 0; i < N-1; i++){
		for(int k = i+1; k < N; k++){
			tmp = table[i]*table[k];
			if(isOK(tmp)){
				maximum = max(maximum,tmp);
			}
		}
	}

	printf("%d\n",maximum);

	return 0;
}

Measured memory_bytes: 2768
a, b = map(int, input().split())
c = 1

for i in range(2, a):
  while a % i ==0:
    if b % i ==0:
      c = c*i
      a = a/i
      b = b/i
    else:
      c = c*i
      a = a/i

c = int(a*b*c)
print(c)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using u64 = uint64_t;

int main() {
	
	char N[3];
	
	cin >> N[0] >> N[1] >> N[2];
	
	if(N[0] == '7' || N[1] == '7' || N[2] == '7') {
		cout << "Yes";
	} else {
		cout << "No";
	}
	
	return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>

int main(void){
  int i,x,n;

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    x=i;
    if(x%3==0){
      printf(" %d",i);
      continue;
    }
    do{
      if(x%10==3){
	printf(" %d",i);
	break;
      }
      x/=10;
    }while(x!=0);
  }
  printf("\n");
}



Measured memory_bytes: 2040
n,m = map(int,input().split())
x = list(map(int,input().split()))
if n>=m:
  print(0)
else:
  x.sort()
  dx = []
  for i in range(m-1):
    dx.append(abs(x[i]-x[i+1]))
  dx.sort()
  print(sum(dx[:m-n]))

Measured memory_bytes: 13968
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<set>
#include<algorithm>
#define ll long long
#define rep(i,a,n) for(ll i=a;i<=n;i++)
#define per(i,a,n) for(ll i=n;i>=a;i--)

using namespace std;
int main()
{
    ll h,n,v;
    scanf("%lld %lld",&h,&n);
    rep(i,1,n)
    {
        scanf("%lld",&v);
        h-=v;
    }
    if(h<=0)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
    int N,T;
    scanf("%d%d",&N,&T);
    int ans=100000;
    for(int i=0;i<N;i++){
        int c,t;
        scanf("%d%d",&c,&t);
        if(t<=T&&ans>c)ans=c;
    }
    if(ans==100000)printf("TLE");
    else printf("%d",ans);
    return 0;
}


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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

/*
while(!frag && cin >> a >>b, a|b)
*/

int main(void){
   int n,m; cin >> n >> m;
   int a[n] = {},b[n] = {};
   rep(i,0,m){
      int c,d; cin >> c >> d;
      c--; d--;
      if(c==0) a[d]=1;
      if(d==n-1) b[c]=1;
   }

   string ans = "IMPOSSIBLE\n";
   rep(i,0,n){
      if(a[i] == 1 && b[i] == 1) ans = "POSSIBLE\n";
   }
   cout << ans;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#define endl '\n'
typedef long long ll;
using namespace std;
ll a[201];
int main()
{
    ll n;
    cin>>n;
    bool flag = true;
    ll turn = 0;
    for(ll i = 0; i<n; i++){
            cin>>a[i];
            if(a[i]%2){
                    flag = false;
                    break;
            }
    }
    while(flag){
            turn++;
        for(ll i = 0; i<n; i++){
            a[i] = a[i]/2;
            if(a[i]%2)flag = false;
        }
    }
    cout<<turn;
    return 0;

}


Measured memory_bytes: 256
n = int(input())
d,x = map(int,input().split())
a = [0]*n

for i in range(0,n):
  a[i] = int(input())
  
ans = 0
for i in range(n):
  day = 1
  j = 1
  while True:
    if day > d:
      break
    else:
      ans += 1
      day = j*a[i] + 1
      j += 1
      
print(ans+x)

Measured memory_bytes: 64272
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define c(n) cin>>n
#define c2(n,m) cin>>n>>m
#define c3(n,m,k) cin>>n>>m>>k
#define co(n) cout<<n<<endl
using namespace std;

int main(){
  string s;
  c(s);
  int a[26]={};
  
  rep(i,0,s.size()){
    a[s[i]-97]++;
  }
  int x=-1;
  char y;
  rep(i,0,26){
    if(a[i]==0){
      x=i+97;
      break;
    }
  }
  if(x==-1) co("None");
  else {
    y=x;
    co(y);
  }
  
  
  return 0;
}


Measured memory_bytes: 512
// https://atcoder.jp/contests/abc089/tasks/abc089_b
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

  bool four = false;
  rep(i, N) {
    string c;
    cin >> c;

    if (c == "Y") {
      four = true;
      break;
    }
  }

  (four) ? cout << "Four" : cout << "Three";
  return 0;
}


Measured memory_bytes: 256
using System.Linq;
using System;

public class Hello{
    public static void Main(){
        // Your code here!
			int n = int.Parse(Console.ReadLine());
			int[] p = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
			
			int count=0;
			int min=int.MaxValue;
			foreach(int a in p)
			{
			    if(a<min)
			    {
			        min = a;
			        count++;
			    }
			}
			
			System.Console.Write(count.ToString());
    }
}


Measured memory_bytes: 31964
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-5;
const ll MOD=1e9+7;
int main(){
    int n,k;cin>>n>>k;
    vector<int> a(n+10),g(k+10);
    for(int i=0;i<n;i++)cin>>a[i];
    g[0]=0;
    for(int i=1;i<=k;i++){
        vector<int> s;
        for(int j=0;j<n;j++){
            if(a[j]>i)continue;
            s.push_back(g[i-a[j]]);
        }
        sort(all(s));
        s.erase(unique(all(s)),s.end());
        bool f=false;
        if(s.size()>=1&&s[0]>0){
            g[i]=0;
            continue;
        }
        for(int j=1;j<s.size();j++){
            if(s[j]>s[j-1]+1){
                g[i]=s[j-1]+1;
                f=true;
                break;
            }
        }
        if(s.size()==1){
            g[i]=1;
        }else if(s.size()>1&&f==false){
            g[i]=s[s.size()-1]+1;
        }
    }
    if(g[k]==0){
        cout<<"Second"<<endl;
    }else{
        cout<<"First"<<endl;
    }
}   


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (int &pi : p) cin >> pi;
    
    
    
    int cnt = 0;
    rep(l, n) {
        int r = l + 1;
        while (r < n && p[r - 1] < p[r]) r++;
        if (r - l >= k) cnt++;
        if (r != l) l = r - 1;
        // cout << l << endl;
    }
    if (cnt) cnt--;
    // cout << cnt << endl; 
  
    set<int> s;
    int mmin = inf, mmax = -inf;
    rep(i, k) {
        s.insert(p[i]);
        chmin(mmin, p[i]);
        chmax(mmax, p[i]);
    }
    
    rep3(i, k, n) {
        int pop_ = p[i - k];
        s.erase(pop_);
        s.insert(p[i]);
        
        mmax = *(--s.end());
        // mminは前の最小値, mmaxは新しい最大値
        if (mmin == pop_ && mmax == p[i]) cnt++;
        mmin = *s.begin();
    }
    
    cnt = (n - k + 1) - cnt;
    cout << cnt << endl;
    
}


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

int main(){
  ll n,k;
  cin >> n >> k;
  if(n==k){
    cout << 0 << endl;
    return 0;
  }
  else if(n>k){
    n = n%k;
    if(n == 0){
      cout << 0 << endl;
      return 0;
    }
  }

  ll border = k/2;
  if(n>border) cout << k-n << endl;
  else cout << n << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int m1,m2,m3,d,i;
	for(i=0;i<10;i++){
		scanf("%d",&d);
		if(d>m1){
			m3=m2;
			m2=m1;
			m1=d;
		}else if(d>m2){
			m3=m2;
			m2=d;
		}else if(d>m3){
			m3=d;
		}
	}
	printf("%d\n",m1);
	printf("%d\n",m2);
	printf("%d\n",m3);
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repk(i,m,n) for(int i=m;i<n;i++)
typedef long long ll;
using namespace std;
int main()
{
    ll a[100002]={};
    ll n,k,q;
    cin>>n>>k>>q;
    rep(i,q)
    {
        ll temp;
        cin>>temp;
        a[temp]++;
    }
    rep1(i,n)
    {
        if(q-a[i]>=k)
            cout<<"No"<<endl;
        else
            cout<<"Yes"<<endl;
    }
}


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

signed main(void)
{
	int n; cin >> n;
	int a[n]; rep(i, n) cin >> a[i];
	ll ans, sum;

	map<ll, ll> m;
	sum = 0; 
	rep(j, n)
		m[a[j]]++;
	for(auto k : m)
	{
		ll value1 = k.second;
		sum += value1 * (value1 - 1) / 2;
	}
	rep(i, n)
	{
		ans = sum;
		ans -= m[a[i]] * (m[a[i]] - 1) / 2;
		ans += (m[a[i]] - 1) * (m[a[i]] - 2) / 2;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 10240
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line: Vec<usize> = read_as_vec();
    //let (n, k) = (line[0], line[1]);
    let n = line[0];
    let mut k = line[1];

    let people = read_as_string();
    let people: Vec<char> = people.chars().collect();
    
    //println!("{:?}",people);

    //find the longest handstanding line

    let (mut i, mut j) = (0, 0);
    while j < n{
        while j < n && people[j] == '1'{
            j += 1;
        }

        if k > 0{
            k -= 1;
        }else{
            break;
        }
        
        while j < n && people[j] == '0'{
            j += 1;
        }
    }
    if j == n{
        println!("{}", j-i);
        return;
    }
    let mut longest : (usize, usize)= (i, j);
    /*
    println!("i = {}, j = {}", i, j);
    println!("k = {}", k);
    */
    loop{   
        while people[i] == '1' && i <=j{
            i += 1;
        }

        k += 1;
        while people[i] == '0' && i <= j{
            i += 1;
        }

        k -= 1;
        while j < n && people[j] == '0'{
            j += 1;
        }
        while j < n && people[j] == '1'{
            j += 1;
        }



        
        if longest.1-longest.0 < j-i{
            longest = (i, j);
        }
        if j >= n{
            break;
        }
    }

    /*
    println!("i = {}, j = {}", i, j);
    println!("k = {}", k);
    */
    println!("{:?}", longest.1-longest.0);
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main()
{
  int n, m, l;
  cin >> n >> m >> l;
  long long a[n][m];
  long long b[m][l];
  long long c[n][l];
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < m; j++)
    {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < m; i++)
  {
    for (int j = 0; j < l; j++)
    {
      cin >> b[i][j];
    }
  }
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < l; j++)
    {
      c[i][j] = 0;
    }
  }

  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < l; j++)
    {
      for (int k = 0; k < m; k++)
      {
        c[i][j] += a[i][k] * b[k][j];
      }
    }
  }

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

Measured memory_bytes: 3328