akhauriyash/Code-Regression huggingface dataset:
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 union(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 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]

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

  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]

  def num_members(self,x):
    return abs(self.parents[self.find(x)])

  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int, input().split())
uf = UnionFind(N)
for i in range(M):
  a,b,c = map(int, input().split())
  uf.union(a-1,b-1)

print(uf.num_roots())

Measured memory_bytes: 13768
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;

inline bool check(ll x, ll y, ll xMax, ll yMax) { return x >= 0 && y >= 0 && xMax > x && yMax > y; }
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string tostring(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }
template<class T> inline T mypow(T x, ll n) { T res = 1; while (n > 0) { if (n & 1)res = res * x;	x = x * x;	n >>= 1; }return res; }
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

#define For(i,a,b)	for(ll (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define rFor(i,a,b)	for(ll (i) = (a-1);i >= (b);(i)--)
#define rrep(i,n)	rFor(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define tostr(a)	tostring(a)
#define dump(val) 	cerr << #val " = " << val << endl;
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

const ll dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = 1e17 + 9;

#define int ll
#define double ld

signed main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	int w, h;
	cin >> w >> h;

	priority_queue<T, vector<T>, greater<T>> qe;
	vector<int> p(w);
	for (int i = 0; i < w; i++) {
		cin >> p[i];
		qe.push(T(p[i], 0, i));
	}
	vector<int> q(h);
	for (int i = 0; i < h; i++) {
		cin >> q[i];
		qe.push(T(q[i], 1, i));
	}

	int tw = w + 1, th = h + 1;
	int ans = 0;

	while (qe.size()) {
		int k, i, t;
		tie(t, k, i) = qe.top();
		qe.pop();
		if (k == 0) {//w
			ans += t * th;
			tw--;
		}
		if (k == 1) {//h
			ans += t * tw;
			th--;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 7920
#include<stdio.h>
#include<string.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
char s[110000];
int n,x[110000],y[110000],now,vt,et;
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	if (s[1]!='1'||s[n]!='0'){
		printf("-1\n");
		return 0;
	}
	now=1;vt=1;
	fo(i,1,n-1){
		if (s[i]!=s[n-i]){
			printf("-1\n");
			return 0;			
		}
		++vt;
		x[++et]=now;
		y[et]=vt;
		if (s[i]=='1') now=vt;
	}
	fo(i,1,et) printf("%d %d\n",x[i],y[i]);
	return 0;
} 

Measured memory_bytes: 2176
#include <bits/stdc++.h>
//Remove below header file if c++ version greater than 14
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
using namespace std;
#define ll long long int
#define pb push_back
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define deb(x) cout << #x << " "<< x << endl;
#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)

const int inf = -1000;
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a /gcd(a, b) *b;
}
typedef pair<int,int> pii;
const int mod = 1e9+7;
int main() {

   int n;
   cin>>n;
   map<string,vector<pii> > mp;
     fo(i,n){

       string s;
       int x;
       cin>>s>>x;

       mp[s].push_back({x,i+1});

   }
   for(auto x:mp){
    sort(x.second.begin(),x.second.end());
    reverse(x.second.begin(),x.second.end());

    for(pii p:x.second)
        cout<<p.second<<"\n";
   }






























    return 0;

      }


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

using namespace std;

int main(){
  int n;
  cin>>n;
  vector<int> v;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    v.push_back(x);
  }
  int dp[200010];
  dp[0]=0;
  dp[1]=0;
  for(int i=2;i<=n;i++){
    dp[i]=dp[i-1] + abs(v[i-1] - v[i-2]);
    if(i>2)
      dp[i]=min(dp[i],dp[i-2] + abs(v[i-1]-v[i-3]));
  }
  cout<<dp[n];
  
  return 0;
}

Measured memory_bytes: 1144
// スタックサイズ: 100MB

#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1e18;
const double EPS = 1e-10;
const ll mod = 1e9 + 7;
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }




int main() {
	fastio;

	string a, b, c;
	cin >> a >> b >> c;
	cout << char(a[0] + 'A' - 'a') << char(b[0] + 'A' - 'a') << char(c[0] + 'A' - 'a') << endl;
}

Measured memory_bytes: 256
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(i64);
    let X = read!(i64; 5);

    let mut s = 0;
    let mut t = 0;
    for x in X {
        let y = (N + x - 1) / x;

        if y > s {
            t += y - s;
            s = y;
        }
        t += 1;
    }
    t -= 1;

    println!("{}", t)
}


Measured memory_bytes: 4352
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
 
using namespace std; 
 
#define NOT_FOUND -1
#define rep(i,n) for(int i=0;i<(int)(n); i++)
/*for文のマクロ定義
rep(i,回数){
    処理
}
*/
 
void swap(int *a, int *b){
	*b=*a-*b;
	*a-=*b;
	*b+=*a;
}
 
int sosu_judge(int N){
	/*素数ならば1
	  素数でなければ0を返す
	*/
	int i,j;
 
	if(N==2)   return 1;
	if(N%2==0) return 0;
 
	for(i=3;i<N && N%i!=0;i+=2);
 
	if(i>=N) return 1;
	
	return 0;
}
 
int factorial(int N){  //Nの階乗を求める関数
	int ans=1;
 
	while(N--) ans*=(N+1);
	return ans;
}
 
//クイックソートをする関数
void q_sort(int a[], int first, int last){
    int i,j;
    int x,t;
 
    x = a[(first + last) / 2];
    i = first; j=last;
 
    while(1){
        while( a[i] < x) i++;
        while( x < a[j]) j--;
        
        if( i >= j) break;
        
        swap(&a[i],&a[j]);
        i++; j--;
    }
    if(first < i-1) q_sort(a, first,i-1 );
    if(last > j+1)  q_sort(a, j+1,  last);
}
 
int b_search(int target, int array[],int right, int left){
    /*二分探索を行う関数である。
      戻り値は探索したい値の格納されている位置である。
      もし値が存在しない場合、NOT_FOUND(-1)を返す
    */
    int mid;
    while(left<right){
        mid=(right+left)/2;
        if(array[mid]<target) left =mid+1;
        else                  right=mid;
    }
    if(array[mid]==target) return mid;
    return NOT_FOUND;
}
 
unsigned long combination(int n, int r){
    /*nCrの値を求める関数である。
      値が巨大になる可能性があるため、戻り地はunsigned longである
    */
    int i,j;
    unsigned long a[17];
 
    if(n-r<r) r=n-r;
    if(r==0 ) return 1;
    if(r==1 ) return n;
    if(r>17 ) return 0;
    for(i=1;i<r;i++) a[i]=i+2;
    for(i=3;i<=n-r+1;i++){
        a[0]=i;
        for(j=1;j<r;j++)a[j]+=a[j-1];
    }
    return a[r-1];
}

int main(){
    string S;

    cin>>S;

    if(S[2]==S[3] && S[4]==S[5]){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
    return 0;
}


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

int mode=1000000007;

int main(){
	int N;
	scanf("%d",&N);
	char S1[N+1];
	char S2[N+1];
	scanf("%s",S1);
	scanf("%s",S2);
	int i=0;
	long int ans=0;
	while(i<N){
		if (ans>mode){
			ans=ans%mode;
		}
		if (i==0){
			if (S1[0]==S2[0]){
				ans+=3;
				i++;
			}
			else{
				ans+=6;
				i+=2;
			}
		}
		else{
			if (S1[i]==S2[i]){
				if (S1[i-1]==S2[i-1]){
					ans=ans*2;
				}
				else{
					ans=ans;
				}
				i++;
			}
			else{
				if (S1[i-1]==S2[i-1]){
					ans=ans*2;
				}
				else{
					ans=ans*3;
				}
				i+=2;
			}
		}
	}
	if (ans>mode){
		ans=ans%mode;
	}
	printf("%ld\n",ans);
	return 0;

}

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

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

  x = a*b;	
	if (x % 2 == 0){
		cout << "Even" << endl;
	} 
  else {
    cout << "Odd" << endl;
  }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;

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




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




int n,k;
cin>>n>>k;

double ans=0;

for(int i=1;i<=n;i++)
{
   int cnt=0;
   int j=i;
   while (j<k)
   {
      cnt++; j<<=1;
   }
   ans=ans+(1.0/n)*pow(0.5,cnt);
   
}
cout<<setprecision(15)<<fixed<<ans<<"\n";


  
}



Measured memory_bytes: 256
// #1140935 Solution for 0515: School Road by ryogo 
#include<iostream>
using namespace std;
int dp[17][17];
int main(){
	int a, b ,i, j, x, y;
	while(cin>>a>>b){
		if(a == 0 && b == 0) { break; }
		int n;
		cin>>n;
		for(i=1;i<=16;i++)for(j=1;j<=16;j++){dp[i][j]=0;}
		for(i=1;i<=n ;i++){
			cin>>x>>y; dp[y][x]=-1;
		}
		dp[1][1]=1;
		for(i=1;i<=b;i++){
			for(j=1;j<=a;j++){
				if(i==1 && j==1)continue;
				if(dp[i][j]!=-1){
					dp[i][j]=dp[i][j-1]+dp[i-1][j];
				}
				else dp[i][j]=0;
			}
		}
 
		cout<<dp[b][a]<<endl;
	}
}


Measured memory_bytes: 3056
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        // ##### 初期読み込み #######################################################################

        // 1行 文字 複数 ----------------------------------------------------------------------------
        String[] stringArray = scanner.nextLine().split(" ");

        int n = Integer.parseInt(stringArray[0]);
        int r = Integer.parseInt(stringArray[1]);


        // ##### メイン処理 #######################################################################

        int result = 0;
        if (n >= 10) {
            result = r;
        } else {
            result = r + 100 * (10 - n);
        }
        System.out.println(result);

    }
}

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

using namespace std;

int main(int argc, char const *argv[]) {
	int N;
	std::cin >> N;
	int a[N];
	// 奇数、偶数、４の倍数を数える
	int odd,even,four;
	odd = even = four = 0;
	for (size_t i = 0; i < N; i++) {
		std::cin >> a[i];
		if (a[i] % 4 == 0) {
			four++;
		}
		else if (a[i] % 2 == 0) {
			even++;
		}
		else{
			odd++;
		}
	}

	if (four >= odd || (four == odd-1 && even == 0)) {
		std::cout << "Yes" << '\n';
	}
	else{
		std::cout << "No" << '\n';
	}

	return 0;
}


Measured memory_bytes: 640
import collections

n=int(input()) 
s = []
c0 = 0
c1 = 0
c2 = 0
c3 = 0

for i in range(n):
    tmp=input()
    s.append(tmp)

c = collections.Counter(s)

c0 = c['AC']
c1 = c['WA']
c2 = c['TLE']
c3 = c['RE']


print('AC x ' + str(c0))
print('WA x ' + str(c1))
print('TLE x ' + str(c2))
print('RE x ' + str(c3))


Measured memory_bytes: 16616
#include <stdio.h>

int main(void) {
    int N,tmp,count=10000;
    
    scanf("%d",&N);
    for(int i = 0; i<=N;i++) {

        tmp = 0;
        int j = i;
        int k = N-j;

        while(j>=1) {
            tmp =tmp + j%6;
            j = j/6;
        }

        while(k>=1) {
            tmp = tmp + k%9;
            k = k/9;
        }
        if(count>tmp) {
            count = tmp;
        }
    }

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

    
}

Measured memory_bytes: 128
/*
                   _ooOoo_
                  o8888888o
                  88" . "88　AC!AC!
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rep3(var, min, max) for (ul (var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ul (var) = (max) - 1; (var) + 1 > (min); --(var))
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; }
typedef pair<ll, ll> P;
typedef vector<ll> V;
ll MOD = 1e9 + 7;
V banboo;
int n,a,b,c;
int dfs(int i,int A,int B,int C){
    if(i==n){
        if(A==0||B==0||C==0)return 1e9;
        return abs(A-a)+abs(B-b)+abs(C-c);
    }
    return min({dfs(i+1,A,B,C),
               (dfs(i+1,A+banboo[i],B,C)+10),
               (dfs(i+1,A,B+banboo[i],C)+10),
               (dfs(i+1,A,B,C+banboo[i])+10)
                });
}
int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    cin>>n>>a>>b>>c;
    banboo.resize(n);
    rep(i,n){
        cin>>banboo[i];
    }
    cout<<dfs(0,0,0,0)-30<<endl;
}
    


Measured memory_bytes: 256
#include <cstdio> 
#include <algorithm>  
#define ll long long   
#define N 2008  
#define mod 924844033 
#define setIO(s) freopen(s".in","r",stdin) 
using namespace std; 
int f[N<<1][N<<1][2],link[N<<1],fac[N<<1];  
int main() 
{ 
    // setIO("input");  
    int i,j,n,k,tot=0; 
    scanf("%d%d",&n,&k);     
    fac[0]=1,f[0][0][0]=1;    
    for(i=1;i<=n;++i) fac[i]=(ll)fac[i-1]*i%mod;     
    for(i=1;i<=k;++i) 
    {
        for(int t=1;t<=2;++t) 
            for(j=i;j<=n;j+=k) 
                if(j!=i) link[++tot]=1; else ++tot;     
    }    
    for(i=1;i<=tot;++i) 
    {
        for(j=0;j<=n;++j) 
        {   
            f[i][j][0]=(ll)(f[i-1][j][0]+f[i-1][j][1])%mod;    
            if(link[i]) f[i][j][1]=f[i-1][j-1][0];      
        }
    }    
    int ans=0; 
    for(i=0;i<=n;++i) 
    {
        int tmp=(ll)(f[n<<1][i][0]+f[n<<1][i][1])%mod;       
        tmp=(ll)tmp*fac[n-i]%mod;      
        if(i&1) ans=(ll)(ans-tmp+mod)%mod;        
        else ans=(ll)(ans+tmp)%mod;   
    }   
    printf("%d\n",ans); 
    return 0; 
}

Measured memory_bytes: 124672
#pragma GCC optimize("Ofast","unroll-loops")
#pragma GCC push_options
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#include <xmmintrin.h>
#include <immintrin.h>
using namespace::std;
__attribute__((constructor))void init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// typedef mp::number<mp::cpp_dec_float<0>> cdouble;
// typedef mp::cpp_int cint;
template<typename T>using pbds=__gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T>using pbds_map=__gnu_pbds::tree<T,T,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T,typename E>using hash_map=__gnu_pbds::gp_hash_table<T,E>;
template<typename T>using pqueue =__gnu_pbds::priority_queue<T, less<T>,__gnu_pbds::rc_binomial_heap_tag>;
typedef long long lint;
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
#define MOD 1000000007LL
//#define MOD 998244353LL
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
template<typename T>inline void numout(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i<INF/2?i:"INF";f=1;}cout<<endl;}
template<typename T>inline void numout2(T t){for(auto i:t)numout(i);}
template<typename T>inline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}
template<typename T>inline void output2(T t){for(auto i:t)output(i);}
template<typename T>inline void _output(T t){bool f=0;for(lint i=0;i<t.size();i++){cout<<f?"":" "<<t[i];f=1;}cout<<endl;}
template<typename T>inline void _output2(T t){for(lint i=0;i<t.size();i++)output(t[i]);}
#define rep(i,n) for(lint i=0;i<lint(n);++i)
#define repi(i,a,b) for(lint i=lint(a);i<(lint)(b);++i)
#define rrep(i,n) for(lint i=lint(n)-1;i>=0;--i)
#define rrepi(i,a,b) for(lint i=lint(b)-1;i>=lint(a);--i)
#define irep(i) for(lint i=0;;++i)
#define all(n) begin(n),end(n)
#define dist(a,b,c,d) sqrt(pow(a-c,2)+pow(b-d,2))
inline lint gcd(lint A,lint B){return B?gcd(B,A%B):A;}
inline lint lcm(lint A,lint B){return A/gcd(A,B)*B;}
// inline cint cgcd(cint A,cint B){return B?cgcd(B,A%B):A;}
// inline cint clcm(cint A,cint B){return A/cgcd(A,B)*B;}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
const vector<lint> dx={1,0,-1,0,1,1,-1,-1};
const vector<lint> dy={0,1,0,-1,1,-1,1,-1};
#define SUM(v) accumulate(all(v),0LL)
auto call=[&](auto f,auto... args){return f(f,args...);};

int main(){
    lint n,h,w;
    cin>>n>>h>>w;
    cout<<(n-h+1)*(n-w+1)<<endl;
}

Measured memory_bytes: 256
#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};
typedef long long ll;
#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 _out(value) cout<<"      "<<value<<en
#define out(value) cout<<value<<en

int shop[100005];
int order[10005];

int main(){
  int d,n,m;
  while(cin>>d&&d){
    cin>>n>>m;
    vector<int> v;
//    for(int i=1; i<n; i++) cin>>shop[i];
    for(int i=1; i<n; i++){
      int s;
      cin>>s;
      v.push_back(s);
    }
    v.push_back(0); v.push_back(d);
//    for(int i=0; i<m; i++) cin>>order[i];
//    shop[0]=0;
    
    ll ans=0;
    sort(v.begin(), v.end());
      
    for(int i=0; i<m; i++){
      int o;
      cin>>o;
      ll w=upper_bound(v.begin(), v.end(), o)-v.begin();
      int nex=v[w];
      w=upper_bound(v.begin(), v.end(), o)-v.begin()-1;
      int pre=v[w];
      ans+=min(abs(o-nex),abs(o-pre));
    }
    
    cout<<ans<<en
  }
}


Measured memory_bytes: 3520
#include <iostream>

#define MAXN 100000
using namespace std;
typedef long long int ll;
int a[MAXN];
int n;
ll sol = 0;
bool pass = false;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (pass) {
            if (a[i] & 1) {
                pass = false;
                a[i]--;
                sol++;
            } else if (a[i] > 1) {
                a[i] -= 2;
                sol++;
            } else if (a[i] == 1) {
                a[i]--;
                sol++;
                pass = false;
            } else {
                pass = false;
            }
        } else {
            if (a[i] & 1) {
                pass = true;
                a[i]--;
            }
        }
    }

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

    cout << sol << "\n";

    return 0;
}

Measured memory_bytes: 768
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextLong()
    val b = sc.nextLong()
    val c = sc.nextLong()

    val s = arrayOf(a, b, c).min()!!
    val l = arrayOf(a, b, c).max()!!
    val m = a + b + c - s - l

    for (v in arrayOf(s, m, l)) {
        if (v % 2 == 0L) {
            println(0)
            return
        }
    }
    println(s * m)
}


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

using namespace std;

int main()
{
    int a,b;
    int d = 0;
    cin >> a >> b;


        for(int i =1;i<= 3;++i)
        {
            if(a*b*i % 2 !=0)
            {
                d = 1;
            }
        }
        if(d == 0)
            cout << "No";
        else
            cout << "Yes";


}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1000000007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

class UnionFind{
    int n;
    vector<int> par;
    vector<int> rank;
    vector<int> sz;

public:
    UnionFind(int n) : n(n), rank(n, 0){
        par.resize(n);
        for(int i=0; i<n; i++)
            par[i] = i;
        sz.resize(n, 1);
    }
    int find(int x){
        if (par[x] == x) return x;
        return par[x] = find(par[x]);
    }
    void unite(int x, int y){
        int x_root = find(x);
        int y_root = find(y);
        if(rank[x_root] > rank[y_root]){
            par[y_root] = x_root;
            sz[x_root] += sz[y_root];
        }else if (rank[x_root] < rank[y_root]){
            par[x_root] = y_root;
            sz[y_root] += sz[x_root];
        }else if (x_root != y_root){
            par[y_root] = x_root;
            sz[x_root] += sz[y_root];
            rank[x_root]++;
        }
    }
    int size(int x){ return sz[find(x)]; }
    bool same(int x, int y){ return find(x) == find(y); }
};

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

    UnionFind uf(N);

    vector<vector<int>> friends(N);
    vector<vector<int>> blocks(N);

    REP(i, M){
        int A, B;
        cin >> A >> B;
        A--; B--;
        friends[A].push_back(B);
        friends[B].push_back(A);
        uf.unite(A, B);
    }
    REP(i, K){
        int C, D;
        cin >> C >> D;
        C--; D--;
        blocks[C].push_back(D);
        blocks[D].push_back(C);
    }
    REP(i, N){
        int sz = uf.size(i);
        int ans = sz - 1 - friends[i].size();
        for(int j : blocks[i])
            if(uf.same(i, j))
                ans--;
        cout << ans << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 13048
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		if (N % 2 != 0) {
			System.out.println("No");
		} else {
			String s = scn.next();
			String s1 = s.substring(0, N / 2);
			String s2 = s.substring(N / 2);
			if (s1.equals(s2)) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}

Measured memory_bytes: 27096
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

int main(){
  string s;
  ll k;
  cin >> s >> k;
  ll ans=0;
  ll n=s.size();
  ll cnt=1;
  char c=s[0];
  bool flag=false;
  for(int i=1;i<n;i++){
    if(s[i]==c) cnt++;
    else{
      if(flag||s[0]!=s[n-1]) ans+=cnt/2*k;
      else ans+=cnt/2;
      cnt=1;
      c=s[i];
      flag=true;
    }
  }
  if(cnt==n) cout << n*k/2 << endl;
  else{
    ans+=cnt/2;
    for(int i=0;i<n;i++){
      if(c==s[i]) cnt++;
      else break;
    }
    ans+=cnt/2*(k-1);
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <unordered_map>
using namespace std;

#define ll long long

int main()
{
    ll X[5];
    scanf("%lld %lld %lld %lld %lld", &X[0], &X[1], &X[2], &X[3], &X[4]);

    ll ans;
    for (ll i = 0; i < 5; i++)
        if (X[i] == 0)
            ans = i + 1;
    printf("%lld\n", ans);
}


Measured memory_bytes: 3864
#include<stdio.h>
int main() {
  int n,i,j,minj,tmp,count=0,flag=0;
  int a[100];
  
  scanf("%d",&n);

  for(i = 0 ; i < n ; i++) {
    scanf("%d",&a[i]);
  }

  for(i = 0 ; i <= n-1 ; i++) {
    minj = i;
    for(j = i ; j <= n-1 ; j++) {
      if(a[j] < a[minj]) {
	minj = j;
      }
    }
    if( minj != i) {
      tmp = a[i];
      a[i] = a[minj];
      a[minj] = tmp;
      count++;      
    }
  }
  
  for(i = 0 ; i < n-1 ; i++) {
    printf("%d ",a[i]);
  }
  printf("%d\n",a[i]);
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2140
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ull unsigned long long 
#define int long long 
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define MAX 1e18
#define PI 3.14159265
const int mod = 1e9 + 7;

int power(int x, int y) 
{ 
   int res = 1;      
  
   
    while (y > 0) 
    { 
       
        if (y & 1) 
            res = (long long)(res*x); 
  
 
        y = y>>1; 
 
        if (x<=100000000)
        x = (long long)(x*x);
 
        //cout<<x<<'\n'; 
    } 
    return res; 
} 


void solve()
{
    std::vector<int>v;
    for(int i=1;i<=5;i++){
        int x;
        cin>>x;
      v.push_back(x);
    }

    int ser=0;
   


    auto it=std::find(v.begin(),v.end(),ser)-v.begin();;

     
    
    auto ans=it+1;
    cout<<ans<<endl;

    return;
}
   
int32_t main()
{
  IOS;
    solve();
    return 0;
}

Measured memory_bytes: 3576
#include<stdio.h>
int main(void)
{
	int n,k,i;
	char s[51];
	scanf("%d %d %s", &n, &k, &s);
	for(i=0; i<n; i++)
	{
		if(i==k-1)
		{
			if(s[i]=='A')
			printf("a");
			if(s[i]=='B')
			printf("b");
			if(s[i]=='C')
			printf("c");
		}
		else
		printf("%c", s[i]);
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,X,n) for(int i=(X);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=(n);i++)
#define Endl endl
/*
long long int gcd(long long int a,long long int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
*/

int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b==c+d){
		cout<<"Balanced"<<endl;
	}
	else if(a+b<c+d){
		cout<<"Right"<<endl;
	}
	else{
		cout<<"Left"<<Endl;
	}
	return 0;
}

Measured memory_bytes: 256
import math

n, h = map(int, input().split())
a, b = [0] * n, [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())

amax = max(a)
cnt = 0
for bi in sorted(b, reverse=True):
    if bi < amax:
        break
    cnt += 1
    h -= bi
    if h <= 0:
        break

if h > 0:
    cnt += math.ceil(h / amax)

print(cnt)

Measured memory_bytes: 12080
#include<bits/stdc++.h>
#define M 998244353
#define N 112345
#define For(i, n) for(int i=0; i<n; i++)
inline int read(){int x=0; int sign=1; register char c=getchar();while(c>'9'||c<'0'){if(c=='-')sign=-1; c=getchar();}while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0'; c=getchar();}return x*sign;}
using namespace std;
typedef long long ll;

ll qpow(ll a, ll b){
	ll ans = 1;
	a %= M;
	for(; b; b >>= 1){
		if (b&1) ans = ((ans * a) % M);
		a = ((a * a) % M);
	}
	return ans;
}

int d[N]; //how many vertices have depth n? 
int n;
int max_d;
int main(){
	n = read();
	for(int i=1; i<=n; i++) { 
		int temp = read(); d[temp]++; max_d = max(temp, max_d);
		if (i == 1 && temp) {cout<<0; return 0;}
	}
	ll ans = 1;
	if (d[0] != 1) {
		cout<<0; return 0;
	}
	for(int i=1; i<=max_d; i++){
		ll t = qpow(d[i-1], d[i]);
		ans *= t;
		ans %= M;
	}
	cout<<ans;
	return 0;
	
}


Measured memory_bytes: 640
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!{
    n: usize,
    s: chars,
    t: chars,
    }
    for i in 0..n{
        print!("{}{}", s[i], t[i])
    }
}

Measured memory_bytes: 4352
#include<iostream>
#include<string>

int main(void)
{
  std::string n;
  std::cin >> n;
  
  for(int i  = 0; i < n.length(); i++) {
    if (n[i] == '1')
      n[i] = '9';
    else
      n[i] = '1';
  }
  
  std::cout << n << std::endl;
  
  return 0; 
}

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

struct edge{
    int to;
    int dist;
    edge(int a, int b){
        to=a;
        dist=b;
    }
};

int n,m,c[100000],NINF=-1e9-7;
vector<edge> v[100000];
set<int> s;

bool f(int a, int b){
    bool g=true;
    if(c[a]==NINF){
        c[a]=b;
        //cout<<"---"<<a<<":c="<<b<<endl;
        for(int i=0;i<v[a].size()&&g;i++){
            g=f(v[a][i].to, c[a]+v[a][i].dist);
        }
    }else if(c[a]!=b){
        //cout<<"---"<<a<<":c="<<c[a]<<"!="<<b<<endl;
        return false;
    }
    return g;
}


int main(void){
    bool h=true;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        s.insert(i);
        c[i]=NINF;
    }
    for(int i=0;i<m;i++){
        int l,r,d;
        cin>>l>>r>>d;
        l--;
        r--;
        v[l].push_back(edge(r,d));
        v[r].push_back(edge(l,-d));
        //s.erase(r);
    }
    for(int i=0;i<n&&h;i++){
        if(c[i]==NINF){
            //cout<<"---"<<i<<":c=0"<<endl;
            h=f(i, 0);
        }
    }

    if(h){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 16640
import Control.Monad
import Control.Applicative
import Data.List
import Data.List.Split

main = do
  xs <- input (map read . splitOn ",") :: IO [[Int]]
  mapM_ print $ solve xs

solve :: [[Int]] -> [Int]
solve xs = foldl f [0,0] xs
  where 
    f [r, l] [x,y,z] | x * x + y * y == z * z = [r+1,l]
                     | x == y = [r,l+1]
                     | otherwise = [r,l]

input :: (String -> a) -> IO [a]
input f = map f . lines <$> getContents 

Measured memory_bytes: 3828
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <functional>
#include <sstream>
#include <string>
#include <iomanip>
using namespace std;
#define LOG(x) cout << #x << " := " << (x) << endl
#define _LOG(x) cout << "Momentai " << x << endl
typedef long long ll;
typedef long double Lf;

ll n, s;

ll f(ll b, ll n) {
    if (n < b) return n;
    else return f(b, n/b) + n%b;
}

ll bns(ll lhs, ll rhs) {
    if (lhs == rhs) return lhs;
    ll mid = (lhs+rhs+1) / 2;
    if (f(mid, n) < s) return bns(lhs, mid-1);
    else return bns(mid, rhs);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin >> n >> s;
    if (s == n) {cout << n+1 << endl; return 0; }
    ll ans = -1;

    int i;
    for (i = 2; n/i > 1e6; ++i) {
        ll lhs = n/i + 1, rhs = n/(i-1);
        if (f(rhs, n) % (i-1) == s % (i-1)) {
            ll x = bns(lhs, rhs);
            if (f(x, n) == s) ans = x;
        }
    }

    for (ll j = 1e6; j >= 2; --j) if (f(j, n) == s) ans = j;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
AB = [0] * N
B = [0] * N
for i in range(N):
    AB[i] = list(map(int, input().split()))
AB.sort()
price = 0
ans = 0
for i in range(N):
    if M <= AB[i][1]:
        ans += AB[i][0] * M
        break
    ans += AB[i][0] * AB[i][1]
    M -= AB[i][1]
print(ans)


Measured memory_bytes: 28092
#include<bits/stdc++.h>
using namespace std;
const int inf=999999999;
int a[1001];
int book[1001];
signed main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	vector<int>v;
	for(int t=1;t<=n;t++)
	{
		for(int i=n;i>=1;i--)
		{
			int sum=0;
			for(int j=1;j<=i;j++)
				sum+=book[j];
			if(a[i]==sum+1)
			{
				book[i]=1;
				v.push_back(a[i]);
				break;
			}
		}
		if(v.size()!=t)
		{
			printf("-1");
			return 0;
		}
	}
	for(int i=0;i<v.size();i++)
		printf("%d\n",v[i]);
	printf("\n");
	return 0;
}


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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
#define ALL(a)  (a).begin(),(a).end()
#define SZ(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    string S; cin >> S;
    ll ans = 0;
    REP(i, S.length() - 1) {
        if (S[i] != S[i + 1]) ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int k,i,j;
    cin>>k>>s;

    j=s.size();
    if(j<=k)
    {   cout<<s<<endl;}
    else if(k<j)
    {
        for(i=0;i<k;i++){ cout<<s[i];}
        cout<<"..."<<endl;
    }
}


Measured memory_bytes: 3596
H, W, d = map(int, input().split())
C = ["R", "Y", "G", "B"]
if d%2==1:
    for i in range(H):
        out = ""
        for j in range(W):
            out += C[(i+j)%4]
        print(out)
elif d%4 == 2:
    for i in range(H):
        out = ""
        for j in range(W):
            out += C[i%2*2+(i//2+j//2)%2]
        print(out)
else:
    for i in range(H):
        out = ""
        for j in range(W):
            out += C[(i+j)//d%2*2+(i-j)//d%2]
        print(out)


Measured memory_bytes: 3316
#include<stdio.h>
int main(){
    int i, j, a, h[3]={0};
    for(i=0; i<10; i++){
        scanf("%d", &a);
        for(j=0; j<3; j++)if(a>h[j]){
            if(j<2)h[2]=h[1],h[1]=h[0];
            h[j]=a;
            break;
        }
    }
    for(i=0; i<3; i++)printf("%d\n", h[i]);
    return 0;
}

Measured memory_bytes: 600
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int n = sc.nextInt();
        for(int i=0; i<n; i++){
            H -= sc.nextInt();
        }
        if(H<=0){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 47760
#include<iostream>
using namespace std;
int main()
{
  int a,b;
  cin >> a >> b;
  int ans;
  if(((a+b)%2) == 0){
    ans = (a+b)/2;
  } else{
    ans = (a+b)/2+1;
  }
  cout << ans;

return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main{
  public static void main(String[] args) throws IOException {
    Scanner sc = new Scanner(System.in);
    sc.next();
    String s = sc.next();
//    String s = "WRWWRWRR";
    char[] chars = s.toCharArray();
    char R ='R', W ='W';
    int i=0, j=chars.length-1, res = 0;
    while ( i <j){
      if(R == chars[j] && W == chars[i]){
        char tmp = chars[j];
        chars[j] = chars[i];
        chars[i] = tmp;
        i++;j--;res++;
      }
      else if(chars[i] == R)
        i++;
      else if(chars[j] == W)
        j--;
    }
//    System.out.println(new String(chars));
    System.out.println(res);
  }

  static class Scanner {
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s) {
      br = new BufferedReader(new InputStreamReader(s));
    }

    public Scanner(FileReader s) throws FileNotFoundException {
      br = new BufferedReader(s);
    }

    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens())
        st = new StringTokenizer(br.readLine());
      return st.nextToken();
    }

    public int nextInt() throws IOException {
      return Integer.parseInt(next());
    }

    public long nextLong() throws IOException {
      return Long.parseLong(next());
    }

    public String nextLine() throws IOException {
      return br.readLine();
    }

    public double nextDouble() throws IOException {
      return Double.parseDouble(next());
    }

    public boolean ready() throws IOException {
      return br.ready();
    }
  }
}

Measured memory_bytes: 37124
from collections import defaultdict
N, M = list(map(int, input().split()))

edge_dict = defaultdict(set)
for i in range(M):
    a, b = list(map(int, input().split()))
    edge_dict[a].add(b)
    edge_dict[b].add(a)

def search(node: int, visited: set):
    visited.add(node)
    if len(visited) == N:
        return 1

    ans = 0
    for next_node in edge_dict[node]:
        if not next_node in visited:
            ans += search(next_node, visited.copy())
    return ans

visited = set()
node = 1
print(search(node, visited))


Measured memory_bytes: 3316
def dfs(current_sum, index, target, nums):
    if current_sum == target:
        return True
    elif current_sum > target:
        return False
    elif index == len(nums):
        return False
    elif current_sum + sum(nums[index:]) < target:
        return False
    else:
        return dfs(current_sum + nums[index], index + 1, target, nums) or dfs(current_sum, index + 1, target, nums)

n = int(input())
a = [int(i) for i in input().split()]
q = int(input())
m = [int(i) for i in input().split()]
for i in m:
    if dfs(0, 0, i, a):
        print("yes")
    else:
        print("no")



Measured memory_bytes: 5624
import math,sys

N, K = map(int, input().split())
window = K - 1
A = list(map(int, input().split()))
# mi_index = A.index(min(A))
# left_count = math.ceil(mi_index / (K - 1))
# right_count = math.ceil((N - (mi_index + 1)) / (K - 1))
# left = mi_index
# right = mi_index
# while left > 0 or right < N-1:
#   if left >= 0 and left > window:
#     left -= window
#   elif N - 1 - right >= window:
#     right += window
  
#   print(left, right)


l = K
count = 1
if l >= N:
  print(count)
  sys.exit()
  
while l < N:
  l += K - 1
  count += 1

print(count)

Measured memory_bytes: 13812
N,A,B,K = map(int,input().split())
MOD = 998244353

MAXN = N+5
fac = [1,1] + [0]*MAXN
finv = [1,1] + [0]*MAXN
inv = [0,1] + [0]*MAXN
for i in range(2,MAXN+2):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = -inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD

def comb(n,r):
    if n < r: return 0
    if n < 0 or r < 0: return 0
    return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD

ans = 0
for a in range(N+1):
    if (K-a*A)%B: continue
    b = (K-a*A)//B
    ans += comb(N,a) * comb(N,b)
    ans %= MOD
print(ans)

Measured memory_bytes: 42956
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
/*vector<Type> v;
vector<Type> v();
vector<Type> v(n);
vector<Type> v(n, d);
vector<vector<Type>> vv;
vector<vector<Type>> vv();
vector<vector<Type>> vv(n);
vector<vector<Type>> vv(n, vector<Type>(m));
vector<vector<Type>> vv(n, vector<Type>(m, d));*/

int main() {
  int n,t,x;
  cin>>n>>x>>t;
  int time;
  if(n%x==0){
    time = n/x*t;
  }else{
    time = (n/x+1)*t;
  }
  cout << time;
  return 0;
}


Measured memory_bytes: 3632
import fractions
from functools import reduce

mod = 10**9 + 7

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
a = list(map(int, input().split()))
a_ = []
for i in range(n):
    a_.append(pow(a[i], mod - 2, mod))

num_lcm = lcm(*a) % mod
ans = 0
for i in range(n):
    ans = (ans + num_lcm * a_[i]) % mod

print(ans)

Measured memory_bytes: 6264
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int H;
int W;
int oppo[12];
char S[13][13];

LL mypow(LL base, LL exp) {
  if (exp == 0) return 1 % MOD;
  LL res = mypow(base*base%MOD, exp/2);
  if (exp%2) res = res*base%MOD;
  return res;
}

int Rank(vector<vector<LL>> &mat) {
  int n = mat.size();
  rep(i, n) {
    if (!mat[i][i]) {
      reps(j, i+1, n) {
        if (mat[j][i]) {
          rep(k, n) {
            swap(mat[i][k], mat[j][k]);
          }
          break;
        }
      }
    }

    if (!mat[i][i]) continue;
    LL v = mypow(mat[i][i], MOD-2);
    rep(k, n) (mat[i][k] *= v) %= MOD;
    assert(mat[i][i] == 1);
    rep(j, n) {
      if (i == j) continue;
      if (!mat[j][i]) continue;
      LL t = mat[j][i];
      rep(k, n) {
        mat[j][k] += MOD;
        mat[j][k] -= mat[i][k]*t % MOD;
        mat[j][k] %= MOD;
      }
      assert(mat[j][i] == 0);
    }
  }

  int ret = 0;
  rep(i, n) {
    if (mat[i][i]) ret++;
  }
  return ret/2;
}


void Try(vector<int> &p, vector<int> &q) {
  rep(i, H) oppo[i] = i;
   
  rep(i, H/2) {
    int a = p[i];
    int b = q[i];
    oppo[a] = b;
    oppo[b] = a;
  }

  vector<vector<LL>> mat(W, vector<LL>(W));
  rep(u, W) {
    mat[u][u] = 0;
    rep(v, u) {
      LL t = 1 + rand() % (MOD-1);
      mat[u][v] = t;
      mat[v][u] = MOD - t;
    }
  }

  rep(i, H) {
    int j = oppo[i];
    rep(k, W) {
      rep(l, k) {
        bool ok = true;
        ok &= S[i][k] == S[j][l];
        ok &= S[i][l] == S[j][k];

        if (!ok) mat[k][l] = mat[l][k] = 0;
      }
    }
  }

  if (Rank(mat) == W/2) {
    puts("YES");
    exit(0);
  }
}

void Brute(vector<int> &p, vector<int> &q) {
  do {
    Try(p, q);
  } while (next_permutation(all(q)));
}

void Dfs(int idx, vector<int> &p, vector<int> &q, bool ped=false) {
  if (idx >= H) {
    if (p.size() == q.size() && p.size() == H/2) {
      Brute(p, q);
    }
    return;
  }

  if (p.size() < H/2) {
    p.eb(idx);
    Dfs(idx+1, p, q);
    p.pop_back();
  }

  if (q.size() < H/2) {
    q.eb(idx);
    Dfs(idx+1, p, q);
    q.pop_back();
  }

  if (!ped && H%2) {
    Dfs(idx+1, p, q, true);
  }
}

int main() {
  scanf("%d%d", &H, &W);
  rep(i, H) {
    scanf(" %s", S[i]);
  }

  vector<int> p, q;
  Dfs(0, p, q);
  puts("NO");
}


Measured memory_bytes: 384