akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+18
#define MOD 1000000007
using namespace std;



int main(){
    int N;
    cin >> N;
    
    int h[N];
    for(int i=0; i<N; i++){
        cin >> h[i];
    }
    
    
    int ans=0;
    

    while(true){
        int top=h[0];
        int top_idx=0;
        
        int flag=0;
        for(int i=0; i<N; i++){
            if(h[i]>0){
                flag=1;
            }
            
            if(h[i]>top){
                top=h[i];
                top_idx=i;
            }
        }
        if(flag==0){
            break;
        }
        
        ans++;
        for(int i=top_idx; i<N; i++){
            if(h[i]==top){
                h[i]--;
            }else{
                break;
            }
        }
        
    }
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

const int N=1e5+5;
int n,a,b;
ll h[N];

bool test(ll k) {
        ll used=0;
        for (int i=0; i<n; i++) {
                if (h[i]-k*b > 0)
                        used += (h[i]-k*b+a-b-1)/(a-b);
        }

        return (used <= k);
}

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

        ll lo=0,hi=1e9;
        while (hi-lo > 1) {
                ll mid=(hi+lo)/2;
                if (test(mid)) hi=mid;
                else lo=mid;
        }

        cout << hi << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#define MAX 10000
#define NIL -1

void setDepth(int,int);
int setHeight(int);
int getSibling(int);
void print(int);

struct node
{
  int p;
  int l;
  int r;
};

struct node T[MAX];
int n,D[MAX],H[MAX];


int main()
{
  int i,v,l,r,root=0;
  scanf("%d",&n);

  for(i=0;i<n;i++)T[i].p=NIL;

  for( i=0;i<n;i++)
    {
      scanf("%d %d %d",&v,&l,&r);
      T[v].l=l;
      T[v].r=r;
      if(l!=NIL)T[l].p=v;
      if(r!=NIL)T[r].p=v;
    }
  for(i=0;i<n;i++)if(T[i].p==NIL)root=i;

  setDepth(root,0);
  setHeight(root);

  for(i=0;i<n;i++)print(i);

    
    
    
  
  return 0;
}

void setDepth(int u, int d)
{
  if(u==NIL)return;
  D[u]=d;
  setDepth(T[u].l,d+1);
  setDepth(T[u].r,d+1);
}

int setHeight(int u)
{
  int h1=0,h2=0;
  if(T[u].l != NIL)h1=setHeight(T[u].l)+1;
  if(T[u].r != NIL)h2=setHeight(T[u].r)+1;

  if(h1>h2) H[u]=h1;
  else H[u]=h2;


  return H[u];
}
      

int getSibling(int u)
{
  if(T[u].p==NIL)return NIL;
  if(T[T[u].p].l!=u && T[T[u].p].l!=NIL )return T[T[u].p].l;
  if(T[T[u].p].r!=u && T[T[u].p].r!=NIL )return T[T[u].p].r;
  return NIL;
}

void print(int u)
{
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("sibling = %d, ",getSibling(u));
  int deg=0;
  if(T[u].l!=NIL)deg++;
  if(T[u].r!=NIL)deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].p==NIL) printf("root\n");
  else if(T[u].l==NIL&&T[u].r==NIL) printf("leaf\n");
  else printf("internal node\n");
  
}



Measured memory_bytes: 2112
function Main(input) {
  input = input.split("\n");
  var W = parseInt(input[0].split(" ")[0]);
  var H = parseInt(input[0].split(" ")[1]);
  var x = parseInt(input[0].split(" ")[2]);
  var y = parseInt(input[0].split(" ")[3]);
  var max=W*H/2;
  var flag=0;
  if(x==W/2&&y==H/2){
    flag=1;
  }
  var ans=max+" "+flag;

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
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(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,y; cin>>x>>y;
    cout<<x+y/2<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef pair<ut,ut> prs;
class UnionFind{
 
	vector<int> unions,talls,sents,dists,sizes;
	int size;
public:
	UnionFind(){}
	UnionFind(int size):size(size){
		init();
	}
	void init(){
	 	unions=vector<int>(size);
	 	talls=vector<int>(size);
	 	sents=vector<int>(size);
	 	dists=vector<int>(size);
	 	sizes=vector<int>(size);
		FOR(i,0,size){
			unions[i]=i;
			sents[i]=0;
			sizes[i]=1;
//			ns[i].PB(pr(0,1));
			talls[i]=1;
		}
	}
	int find(int x,int t=0){
		if(unions[x]==x || sents[x]>t) return x;
		return unions[x]=find(unions[x],t);
 
	}
	int minisize(int x){
		if(x==unions[x]) return sizes[x];
		return minisize(find(x));
	}
	bool isFriend(int a,int b,int t=0){
		return find(a,t)==find(b,t);	
	}
	void unite(int a,int b,int t=0){
		if(isFriend(a,b,t)) return;
		a=find(a,t);
		b=find(b,t);
		if(a>b) unite(b,a,t);
		else{
 			sizes[a]+=sizes[b];
			sents[b]=t;
			talls[a]=max(talls[a],talls[b]+1);
			unions[b]=a;
			dists[b]=1;
//			ns[a].PB(pr(t,ns[b].back().second+ns[a].back().second));
		}
	}
};
inline void IN(ut &x){cin >> x;}
inline void INA(ut n,ut x[]){REP(i,n) cin >> x[i];}
inline void INE(ut m,VI edges[]){
	ut a,b;
	REP(i,m){
		cin >> a >> b;
		edges[a].PB(b);
		edges[b].PB(a);
	}
}
inline void INEC(ut m,Vpr edges[]){
	ut a,b,c;
	REP(i,m){
		cin >> a >> b >> c;
		edges[a].PB(pr(c,b));
		edges[b].PB(pr(c,a));
	}
}
const int SIZE=5+2*1e5;
const int INF=10+1e9;
const LL p=7+1e9;
Vpr wc;
VI edges[SIZE];
LL mini[SIZE],miniall;
UnionFind uf;
LL N,X,Y;
void tryToUnite(int i,int j){
	if(wc[j].second!=wc[i].second && wc[j].first+wc[i].first<=Y){
		uf.unite(i,j);
	}
	else if(wc[j].second==wc[i].second && wc[j].first+wc[i].first<=X){
		uf.unite(i,j);
	}
}
VI balls[SIZE];
LL power(LL x,LL r){
	if(r==0) return 1;
	LL half=power(x,r/2);
	LL ans=1;
	if(r&1) ans*=x;
	ans*=half;
	ans%=p;
	ans*=half;
	return ans%p;
}

LL gyaku(LL x){
	return power(x,p-2)%p;
}

LL nCr(LL n,LL r){
	LL ans=1;
	REP(i,r){
		ans*=n-i;
		ans%=p;
		ans*=gyaku(i+1);
		ans%=p;
	}
	return ans%p;
}
int main(){
	cin >> N >> X >> Y;
	LL a,b,w,c;
	REP(i,N){
		cin >> a >> b;
		wc.PB(pr(b,a));
	}
	uf=UnionFind(SIZE);

	REP(i,SIZE) mini[i]=-1;
	sort(ALL(wc));
	REP(i,N){
		if(i==0 or wc[i].second!=wc[i-1].second){
			REP(j,N){
				tryToUnite(i,j);
			}
			if(i!=0) i=N;
		}
	}
	REP(i,N){
		LL nw=wc[i].first,nc=wc[i].second;
		if(mini[nc]==-1) mini[nc]=i;
	}
	REP(i,N){
		tryToUnite(i,mini[wc[i].second]);
	}
	REP(i,N){
		balls[uf.find(i)].PB(wc[i].second);
	}
	LL ans=1;
	REP(i,N){
		if(balls[i].size()==0) continue;
		sort(ALL(balls[i]));
		LL nokori=balls[i].size();
		LL now=0;
		REP(j,balls[i].size()){
			now++;
			if(j+1==balls[i].size() or balls[i][j]!=balls[i][j+1]){
				ans*=nCr(nokori,now);
				ans%=p;
				nokori-=now;
				now=0;

			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 24172
h,w = map(int,input().split())
F = [input() for _ in range(h)]

MW = [[0]*w for _ in range(h)]
MH = [[0]*w for _ in range(h)]


for i in range(h):
  l = 0
  c = 0
  for r in range(w):    
    if F[i][r] == '#':
      for k in range(l,r):
        MW[i][k] = c
      l = r+1
      c = 0      
    else:
      c += 1
  for k in range(l,r+1):
    MW[i][k] = c  
    
for i in range(w):
  u = 0
  c = 0
  for b in range(h):    
    if F[b][i] == '#':
      for k in range(u,b):
        MH[k][i] = c
      u = b+1
      c = 0      
    else:
      c += 1
  for k in range(u,b+1):
    MH[k][i] = c      
    
ans = 0    
for i in range(h):
  for j in range(w):
    tmp = 0
    if F[i][j] != '#':
      tmp = MH[i][j]+MW[i][j] -1 
    ans = max(ans,tmp)
    
print(ans)

Measured memory_bytes: 123224
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
//#include<unordered_set>
#include<bitset>
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<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
int main(){
	
	int a,b;
	cin>>a>>b;
	if(a%2==0 || b%2==0)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,sum=0;
	cin>>a>>b;
	for(int i=a;i<=b;i++)
	{
		int x=i;
		if((x%10)==(x/10000)&&((x/10)%10)==((x/1000)%10))
		sum++;
	}
	cout<<sum;
} 

Measured memory_bytes: 256
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<array>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<stack>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
#define int long long
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
int b[15];
int cost[15];
int inc[15][15];
int n,m,k;
int ans=1e18;
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++){
		cin>>cost[i];
		for(int j=1;j<=m;j++)
			cin>>inc[i][j];
	}
	while(b[0]==0){
		int cosT=0;
		for(int i=1;i<=n;i++)
			cosT+=b[i]*cost[i];
		for(int i=1;i<=m;i++){
			int sum=0;
			for(int j=1;j<=n;j++)
				sum+=inc[j][i]*b[j];
			if(sum<k)
				goto End;
		}
		ans=min(ans,cosT);
		End:
		int j=n;
		while(b[j]==1){
			b[j]=0;
			j--;
		}
		b[j]=1;
	}
	if(ans==1e18)
		cout<<-1;
	else
		cout<<ans;
	return 0;
}

Measured memory_bytes: 3664
import fractions
import functools

def lcm(a,b):
    return a*b//fractions.gcd(a,b)

def ans(numbers):
    return functools.reduce(lcm,numbers,1)

if __name__ == '__main__':
    N=int(input())
    T=[]
    for i in range(N):
        T.append(int(input()))
    print(ans(T))



Measured memory_bytes: 5436
#include <bits/stdc++.h>
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	long long int a,b,v,w,t;
	cin>>a>>v>>b>>w>>t;
	if(t*(v-w)>=abs(a-b))
    {
        cout<<"YES\n";
    }
    else
    {
        cout<<"NO\n";
    }
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

using namespace std;

typedef long long LL;
typedef vector<LL> VL;
#define REPD(i,a,b) for (LL i=(a);i<(b);i++)
#define REP(i,n) REPD(i,0,n)

LL inputValue(){
  LL a;
  cin >> a;
  return a;
};

string inputString(){
  string a;
  cin >> a;
  return a;
};

vector<LL> inputVector(LL a){
  vector<LL> rv;
  REP(i, a){
    LL input;
    cin >> input;
    rv.push_back(input);
  }
  return rv;
}

vector<string> inputVectorString(LL a){
  vector<string> rv;
  REP(i, a){
    string input;
    cin >> input;
    rv.push_back(input);
  }
  return rv;
}
vector<vector<LL>> inputVector2D(LL a, LL b){
  vector<vector<LL>> rv;
  REP(i, a){
    rv.push_back(vector<LL>());
    REP(j, b) {
      LL input;
      cin >> input;
      rv.at(i).push_back(input);
    }
  }
  return rv;
}

#if 1
#define debug(d) debug1(__LINE__,#d, d)
void debug1(LL line, const char* name, vector<LL>& v) {
  cout << line << ":" << name << ":vector<LL>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    cout << v.at(i) << " ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, LL i) {
  cout << line << ":" << name << ":LL " << i << endl;;
}
void debug1(LL line, const char* name, vector<string>& v) {
  cout << line << ":" << name << ":vector<string>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    cout << v.at(i) << " ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, vector<vector<LL>>& v) {
  cout << line << ":" << name << ":vector<vector<LL>>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    REP(j, (LL)v.at(i).size()) {
      cout << v.at(i).at(j) << " ";
    }
    cout << ", ";
  }
  cout << endl;
}
#else
#define debug(n)
#endif

int main(int argc, const char * argv[]) {
	cout.precision(16);
  // source code
  auto a = inputValue();
  auto b = inputValue();
  LL r = 0;
  LL x = 1;
  for (;x < b;) {x -= 1; x += a; r++;}
  cout << r << endl;


  return 0;
}


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

int main(void){
    char s[4]; 

    scanf("%s", s);

    if(s[1] == 'B'){
        printf("ARC\n");
    }else{
        printf("ABC\n");
    }

    return 0;

} 


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

typedef long long ll;
const int maxn=131072+10;
const ll inf=1e18;
int n,ch[maxn][2],v[maxn][2];
vector<pair<ll,ll> > vec[maxn];
ll mid;

void dfs(int pos){
	if(!ch[pos][0])
		return;
	vec[pos].clear();
	int x=ch[pos][0],y=ch[pos][1];
	vector<pair<ll,ll> > tmp;
	ll maximum=mid-v[pos][0]-v[pos][1];
	for(int i=0;i<vec[x].size();++i){
		vector<pair<ll,ll> >::iterator p=upper_bound(vec[y].begin(),vec[y].end(),make_pair(maximum-vec[x][i].second,inf));
		if(p!=vec[y].begin()){
			--p;
			tmp.push_back(make_pair(vec[x][i].first+v[pos][0],p->second+v[pos][1]));
		}
	}
	for(int i=0;i<vec[y].size();++i){
		vector<pair<ll,ll> >::iterator p=upper_bound(vec[x].begin(),vec[x].end(),make_pair(maximum-vec[y][i].second,inf));
		if(p!=vec[x].begin()){
			--p;
			tmp.push_back(make_pair(vec[y][i].first+v[pos][1],p->second+v[pos][0]));
		}
	}
	sort(tmp.begin(),tmp.end());
	if(!tmp.empty()){
		vec[pos].push_back(tmp.front());
		for(int i=1;i<tmp.size();++i)
			if(tmp[i].second<vec[pos].back().second)
				vec[pos].push_back(tmp[i]);
	}
}
inline bool chk(){
	for(int i=n;i;--i)
		dfs(i);
	return !vec[1].empty();
}

int main(){
	scanf("%d",&n);
	for(int i=2,a,b;i<=n;++i){
		scanf("%d%d",&a,&b);
		if(ch[a][0])
			ch[a][1]=i,v[a][1]=b;
		else
			ch[a][0]=i,v[a][0]=b;
	}
	for(int i=1;i<=n;++i)
		if(!ch[i][0])
			vec[i].push_back(make_pair(0,0));
	mid=2;
	ll l=0,r=(ll)maxn*maxn;
	while(l<r){
		mid=l+r>>1;
		if(chk())
			r=mid;
		else
			l=mid+1;
	}
	printf("%lld\n",l);
	return 0;
}

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

using namespace std;

int main()
{
	long int a;
	long int b;
	long int c;
	cin >> a >> b >> c;
	if(a%2==0 || b%2==0 || c%2==0)
	{
		cout << 0;
	}
	else
	{
		cout << min(a*b,min(b*c,a*c));
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,H,W,h,w,count=0;cin>>N>>H>>W;
  for(int i=0;i<N;i++){
    cin>>h>>w;
    if(H<=h && W<=w)count++;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,d,in;
    cin>>k>>d;
    if(k<10&&d!=0)
    {
        in=(10-k)*100+d;
    }
    else
    {
        in=d;
    }
    cout<<in<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<functional>
#include<limits.h>
#include<string.h>
#include<stack>
#include<list>
#include<deque>
#define int long long
#define mod 1000000007
using namespace std;

char a[300000], b[300000];
signed main() {
	int n, q; cin >> n >> q;
	string s; cin >> s;
	for (int i = 0; i < q; i++) { cin >> a[i] >> b[i]; 
	if (n == 1 && a[i] == s[0]) {
		puts("0");
		return 0;
	}
	}
	int l = -1, r = n;
	while (r-l>1)
	{
		int t = (l + r) / 2; int u = t;
		for (int i = 0; i < q; i++) {
			if (s[t] == a[i]) {
				if (b[i] == 'L')t--;
				else t++;
				if (t < 0)break;
				if (t >= n) {
					r = u; goto k;
				}
			}
			if (i + 1 == q) {
				r = u; goto k;
			}
		}
		l = u;
	k:;
	}
	int ans = r;
	reverse(s.begin(), s.end());
	l = -1, r = n;
	while (r - l>1)
	{
		int t = (l + r) / 2; int u = t;
		for (int i = 0; i < q; i++) {
			if (s[t] == a[i]) {
				if (b[i] == 'R')t--;
				else t++;
				if (t < 0)break;
				if (t >= n) {
					r = u; goto w;
				}
			}
			if (i + 1 == q) {
				r = u; goto w;
			}
		}
		l = u;
	w:;
	}
	cout << n - ans - r << endl;
}

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

int main(){
    int N;
    string S;
    cin >> N >> S;
    int slime_num = N;
    for(int i = 0; i < S.size()-1; i++){
        if(S[i] == S[i+1]) slime_num -= 1;
    }
    cout << slime_num << endl;
    return 0;
}

Measured memory_bytes: 512
n,k=map(int,input('').split(' '))
p=input('')
p=p.split(' ')
for a in range(n):
    p[a]=int(p[a])

l=[]
for a in range(1001):
    l.append(0)

for a in range(n):
    l[p[a]]+=1

h=0
q=0
c=0
s=0
while c==0:
    if l[h]>0:
        l[h]-=1
        q+=h
        s+=1
    else:
        h+=1
    
    if s==k:
        c=1
    else:
        c=0

print(q)

Measured memory_bytes: 9236
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define int long long
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	int n=read();
	int ans=n-1;
	for(int i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			if(i+n/i-2<ans) ans=i+n/i-2;
		}
	}
	cout<<ans<<endl;
#ifdef __LOCAL__
	printf("Time Used : %d\n",clock());
#endif
	return 0;
}



Measured memory_bytes: 256
until(n,m=gets.split.map(&:to_i)).all?(&:zero?)do
r,p,a=[],[],[]
n.times{r.unshift(gets.gsub("?",".").split)}
m.times{p<<gets.split}
p.each{|p|r.each{|r|if p[0]=~/#{r[1]}/&&p[1]=~/#{r[2]}/
a<<p*" "if r[0]!="deny"
break
end}}
puts a.size,a
end

Measured memory_bytes: 9448
#include <iostream>
#include <map>

using namespace std;

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

    map<int, int> m;
    while (n--) {
        int a;
        cin >> a;
        ++m[a];
    }
    int ans = 0;
    for (auto& p : m) {
        if (p.second % 2 != 0) ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4864
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <random>
#include <vector>
 
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
 
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(a) (a).begin(), (a).end()

int main()
{
	int n;
	cin>>n;
	vi a(n);
	int cnt=0;
	rep(i,n){
		cin>>a.at(i);
		if(a.at(i)<=0){
			cnt++;
		}
	}
	ll ans=0;
	if(cnt%2==0){
		rep(i,n){
			ans+=abs(a.at(i));
		}
		cout<<ans<<endl;
		return 0;
	}
	sort(all(a));
	vi ng,ps;
	ng.push_back(0);
	ps.push_back(0);
	rep(i,n){
		if(a.at(i)<0){
			ng.push_back(-1*a.at(i));
		}else{
			ps.push_back(a.at(i));
		}
	}
	rep(i,ng.size()){
		if(i!=ng.size()-1){
			ans+=ng.at(i);
		}
	}
	rep(i,ps.size()){
		if(i!=1){
			ans+=ps.at(i);
		}
	}
	if(ps.size()==1){
		ans-=ng.at(ng.size()-1);
	}else{
		if(ng.at(ng.size()-1)>ps.at(1)){
			ans+=ng.at(ng.size()-1);
			ans-=ps.at(1);
		}else{
			ans-=ng.at(ng.size()-1);
			ans+=ps.at(1);
		}
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1276
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String arg[] =  sc.nextLine().split(" ", 2);


		int a = Integer.parseInt(arg[0]);
		int b = Integer.parseInt(arg[1]);

		if (a * b % 2 == 1) {
			System.out.println("Odd");
		} else {
			System.out.println("Even");
		}


	}

}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pob pop_back
#define MP make_pair
#define VI vector<int>
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.F<<","<<_p.S<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}

template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5;
const ll MOD=1000000007;
const ll INF=(ll)1e18;

ii d[MAXn];
ll dp[MAXn];

int main(){
	IOS();
	ll n,m,k;
	cin>>n>>m>>k;
	REP(i,n)REP(j,m){
		ll tmp;cin>>tmp;
		d[tmp]=MP(i,j);
	}
	for(int i=k+1;i<=n*m;i++){
		dp[i]=dp[i-k]+abs(d[i].F-d[i-k].F)+abs(d[i].S-d[i-k].S);
	}
	ll q;cin>>q;
	while(q--){
		ll l,r;
		cin>>l>>r;
		ll ans=dp[r]-dp[l];
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {

    private static int N;
    private static int[] P;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        P = new int[N];
        for (int i = 0; i < N; i++) {
            P[i] = sc.nextInt();
        }
        System.out.println(solve());
    }

    private static int solve() {
        int[] seq = new int[N+1];

        int max = 0;
        for (int i = 0; i < N; i++) {
            int p = P[i];
            seq[p] = seq[p-1] + 1;
            max = Math.max(seq[p], max);
        }

        return N - max;
    }
}


Measured memory_bytes: 66408
import java.util.Scanner;

public class Main {
  public static void main(String[] args) throws Exception {
    Scanner scanner = new Scanner(System.in);
    try {
      int n = scanner.nextInt();
      int a = scanner.nextInt();
      int b = scanner.nextInt();
      int[] cnt = new int[3];

      for (int i = 0; i < n; i++) {
        int p = scanner.nextInt();
        if (p <= a) {
          cnt[0]++;
        } else if (a < p && p <= b) {
          cnt[1]++;
        } else {
          cnt[2]++;
        }
      }

      int ans = cnt[0];
      for (int i = 1; i < 3; i++) {
        if (ans > cnt[i]) ans = cnt[i];
      }
      System.out.print(ans);
    } finally {
      scanner.close();
    }
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
 
#define vi vector<int>
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define ii pair<int,int>
#define qu queue <int>
#define qmax priority_queue <int>
#define qmin priority_queue <int, vector<int>,greater<int>>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int a, b, x;
    cin>>a>>b>>x;

    if((x <= a+b) && (x>=a))
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;

    return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<queue>
#define LL long long
using namespace std;
inline int read( )
{
  int sum=0;char c=getchar( );bool f=0;
  while(c<'0'||c>'9') {if(c=='-') f=1;c=getchar( );}
  while(c>='0'&&c<='9') {sum=sum*10+c-'0';c=getchar( );}
  if(f) return -sum;
  return sum;
}
const int N=500005;
int n,to[N][30],f[N][20];char s[N];
int main( )
{
  int i,j,l,r;
  scanf("%s",s+1);
  n=strlen(s+1);
  for(i=n;i>=1;i--)
    {
      to[i][s[i]-'a']=i+1;
      for(j=s[i]-'a'+1;j<=26;j++)
        to[i][j]=to[to[i][j-1]][j-1];
      for(j=0;j<s[i]-'a';j++)
	to[i][j]=to[to[i][26]][j];
    }
  for(i=1;i<=n;i++) f[i][0]=to[i][26];
  for(j=1;j<=19;j++)
    for(i=1;i<=n;i++)
      f[i][j]=f[f[i][j-1]][j-1];
  int T=read( );
  while(T--)
    {
      l=read( );r=read( )+1;
      for(j=19;j>=0;j--)
	if(f[l][j]&&f[l][j]<=r) l=f[l][j];
      puts(l==r?"Yes":"No");
    }
  return 0;
}

Measured memory_bytes: 98816
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for ( int i=1; i<=int(n); i++ )  
#define MP make_pair
#define PB push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define X first
#define Y second
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;
typedef pair<LL, int> pii;
typedef long double LD;
const int INF = 0x3f3f3f3f;

template <class T>  
inline bool RD(T &ret) {  
        char c; int sgn;  
        if (c = getchar(), c == EOF) return 0;  
        while (c != '-' && (c<'0' || c>'9')) c = getchar();  
        sgn = (c == '-') ? -1 : 1 , ret = (c == '-') ? 0 : (c - '0');  
        while (c = getchar(), c >= '0'&&c <= '9') ret = ret * 10 + (c - '0');  
        ret *= sgn;  
        return 1;  
}  
template <class T>  
inline void PT(T x) {  
        if (x < 0) putchar('-') ,x = -x;  
        if (x > 9) PT(x / 10);  
        putchar(x % 10 + '0');  
}

const int N = 1e5 + 100;

int a[N];
int main() {
	int n;
	cin >> n;
	for(int i = 1; i <= n; i ++) scanf("%d", &a[i]);
	int K = 0;
	while(true) {
		K ++;
		int odd = 0, even = 0, gcd = 0;
		bool f = 1;
		for(int i = 1; i <= n; i ++) {
			if(a[i] & 1) {
				if(a[i] == 1) f = 0;
				odd ++;
				if(gcd == 0) gcd = a[i] - 1;
			  	else if(a[i] - 1 == 0) gcd = gcd;	
				else gcd = __gcd(gcd, a[i] - 1);
			}
			else {
				gcd = __gcd(gcd, a[i]);
				even ++;
			}
		}
		if(even % 2) return puts(K % 2 ? "First" : "Second") * 0;
		else {
			if(odd == 1 && f) {
				for(int i = 1; i <= n; i ++) a[i] /= gcd;
			}
			else return puts(K % 2 ? "Second" : "First") * 0;
		}
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
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;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

void solve(){
    ll n;cin>>n;
    vl a(n);rep(i,n)cin>>a[i];
    ll q;cin>>q;
    vl m(q);rep(i,q)cin>>m[i];

    set<ll> can;
    rep(i,1<<n){
        ll sum=0;
        rep(j,n){
            if((i>>j&1)==1)sum+=a[j];
        }
        can.insert(sum);
    }
    rep(i,q){
        cout<<(can.count(m[i])?"yes":"no")<<endl;
    }
}

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



Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std ;
int main() { 
    long long int a , b , c , d ;
    cin >> a >> b >> c >> d ;
    long long int ans1 , ans2 , ans3 , ans4 ;
    ans1 = a * c ;
    ans2 = a * d ; 
    ans3 = b * c ;
    ans4 = b * d ; 
    vector<long long int> temp ;
    temp.push_back( ans1 ) ;
    temp.push_back( ans2 ) ;
    temp.push_back( ans3 ) ;
    temp.push_back( ans4 ) ;
    sort(temp.begin() , temp.end()) ;
    cout<<temp[temp.size()-1]<<endl;
}

Measured memory_bytes: 3504
#include <iostream>
using namespace std;
int main(){	
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;	

	bool cont=1;
	for(int i=1;i<10;i++){
		for(int j=1;j<10;j++){
			if(i*j==n){
				cont=0;
				break;
			}
		}
	}
	
	if(!cont){
		cout << "Yes\n";
	}
	else	cout << "No\n";

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
constexpr int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1};
using std::cout;
using std::endl;
using std::cin;

int main(){
	int h, w; cin >> h >> w; std::vector<std::string> s(h);
	for(int i = 0; i < h; i++) cin >> s[i];
	
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(s[i][j] == '.') continue;
			bool f = true;
			for(int k = 0; k < 4; k++){
				int nx = i + vy[k], ny = j + vx[k];
				if(nx<0||ny<0||nx>=h||ny>=w||s[nx][ny] == '.') continue;
				f = false;
			}
			
			if(f){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	
	cout << "Yes" << endl;
	return 0;
}


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


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

    while((a % k != 0) && (a < b)){
        a = a + 1;
    }
    if(a%k == 0){
      cout << "OK";
    } else{
        cout << "NG";
    }
    }
    




//stoi('213')

//to_string

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

int main() {
    //
    int num;
    int Max = 0;
    int sum = 0;

    cin >> num;

    for (int i = 0; i < num; i++) {
        int tmp;
        cin >> tmp;
        Max = max(Max, tmp);
        sum += tmp;
    }

    sum -= Max / 2;
    cout << sum;
    //
}


Measured memory_bytes: 3576
import sys
readline = sys.stdin.buffer.readline


class SegmentTree:
    def __init__(self, N, func, I):
        self.N = N
        self.sz = 2**(N-1).bit_length()
        self.func = func
        self.I = I
        self.seg = [I] * (self.sz * 2)

    def assign(self, k, x):
        self.seg[k + self.sz] = x

    def build(self):
        for i in reversed(range(self.sz - 1)):
            self.seg[i + 1] = self.func(self.seg[2 * i + 2], self.seg[2 * i + 3])

    def update(self, k, x):
        k += self.sz
        self.seg[k] = x
        while k > 1:
            k >>= 1
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])

    def query(self, a, b):
        L = self.I
        R = self.I
        a += self.sz
        if b == self.N:
            b = self.sz
        b += self.sz
        while a < b:
            if a & 1:
                L = self.func(L, self.seg[a])
                a += 1
            if b & 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a >>= 1
            b >>= 1
        return self.func(L, R)


def main():
    def gcd(a, b):
        while b:
            a, b = b, a % b
        return a
    N = int(readline())
    L = map(int, readline().split())
    seg = SegmentTree(N, gcd, 0)
    for i, n in enumerate(L):
        seg.assign(i, n)
    seg.build()
    ans = 1
    for i in range(N):
        ans = max(ans, gcd(seg.query(0, i), seg.query(i+1, N)))
    print(ans)


main()

Measured memory_bytes: 60528
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define TRUE 1
#define FALSE 0
struct node{
  int key;
  struct node* right;
  struct node* left;
  struct node* parent;
};
struct node *root,*NIL;

void insert(int data){
  struct node *p = NIL;
  struct node *x = root;
  struct node *new;

  new =(struct node*)malloc(sizeof(struct node));
  new->key = data;
  new->left = NIL;
  new->right = NIL;

  //x が root ではない。つまり、値が代入されていない。または、全て出力された場合。
  while(x != NIL){
    p = x;
    if(new->key < x->key){
      x  = x->left;
    }else{
      x = x->right;
    }
  }
  new->parent = p;
  if(p == NIL){
    root = new;
  }else{
    if(new->key < p->key){
      p->left = new;
    }else{
      p->right = new;
    }
  }
}

void inorder(struct node *u){
  if(u == NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(struct node *u){
  if(u == NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

void print(){
  inorder(root);
  printf("\n");
  preorder(root);
  printf("\n");
  return;
}
int find(int data,struct node* temp){
  //data != NILすなわち値がない行き詰まりの時、かつ、keyの値と同じ値が見つからない間
  while(temp != NIL && data != temp->key){
    if(temp->key > data)temp = temp->left;
    else temp = temp->right;
  }
  if(temp == NIL)return FALSE;
  else return TRUE;
}

int main(){
  int n,i,x,temp,ans;
  char com[10];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",com);
    if(strcmp("insert",com) == 0){
      scanf("%d",&temp);
      insert(temp);
    }else if(strcmp("print",com) == 0){
      print();
    }else if(strcmp("find",com) == 0){
      scanf("%d",&temp);
      ans = find(temp,root);
      if(ans == TRUE)printf("yes\n");
      else printf("no\n");
      //rootからスタートして、tempの値があるかどうかを探索する。
    }else{
      printf("command error!\n");
    }
  }
  return 0;
}





Measured memory_bytes: 20444
#include <bits/stdc++.h>
using namespace std;
int main()
{string s;long long c=0;
    cin>>s;
    if(s.length()==1)
    {
        if(s[0]=='R')
        cout<<1;
        else
        cout<<0;
    }
    else
    {
        for(long long j=1;j<3;j++)
        {
            if(s[j]==s[j-1]&&s[j]=='R')
            c+=2;
        }
        if(c==4)
        c=3;
        if(c==0)
        {
            if(s[0]=='R'||s[1]=='R'||s[2]=='R')
            c=1;
        }
        cout<<c;
    }
}

Measured memory_bytes: 3624
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    int a,b,c,i;
    cin >> a >> b;
    c=b;
    for(i=0;i<a;i++)
    {
        c*=100;
    }
    if(b==100)
        c=c+pow(100,a);
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    n = int(input())
    arr = [[]] * n
    for i in range(n):
        a, b = map(int, input().split())
        arr[i] = [a, b]
    arr.sort(key = lambda x: x[1])
    ok = 1
    s = 0
    for i in range(n):
        s += arr[i][0]
        if s > arr[i][1]:
            ok = 0
            break
    if ok:
        print("Yes")
    else:
        print("No")
    return 0

main()

Measured memory_bytes: 38084
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
using namespace std;
const int maxn=2e5+10;
int n;long long ans=1e18;
struct ddl{int x,y;}a[maxn];multiset<int> A,B;
inline bool operator <(ddl a,ddl b){return a.x<b.x;}
int main(){
	scanf("%d",&n);
	rep(i,1,n){
		scanf("%d%d",&a[i].x,&a[i].y);
		if(a[i].x>a[i].y) swap(a[i].x,a[i].y);
		A.insert(a[i].x);B.insert(a[i].y);
	}
	sort(a+1,a+n+1);
	rep(i,1,n){
		A.erase(A.find(a[i].x));
		B.insert(a[i].x);
		B.erase(B.find(a[i].y));
		A.insert(a[i].y);
		ans=min(ans,1ll*(*A.rbegin()-*A.begin())*(*B.rbegin()-*B.begin()));
	}
	printf("%lld\n",ans);
	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll x[55];
ll y[55];

ll f(int level, ll X) {
  if (level < 0) return 0;
  if (level == 0) {
    if (X == 1) return 1; else return 0;
  }

  if (X <= 1) return 0;
  else if (X <= 1 + x[level-1]) {
    return f(level - 1, X-1);
  }
  else if (X <= 2 + x[level-1]) {
    return 1 + f(level - 1, X-2);
  }
  else if (X <= 2+ 2*x[level-1]) {
    return 1 + y[level-1] + f(level-1, X-2-x[level-1]);
  }
  else return y[level];
}


int main2() {
  int N; cin >> N;
  ll X; cin >> X;

  x[0] = 1;
  y[0] = 1;
  REP(i, 50) x[i+1] = x[i] * 2 + 3;
  REP(i, 50) y[i+1] = y[i] * 2 + 1;

  ll ans = f(N, X);
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

bool solve(string S){
    int lenS = S.length();
    int lim = lenS/2;
    rep(i, lim){
        if(S[i] != S[lenS-1-i]) return false;
    }
    return true;
}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S; cin >> S;
    string L = "", R = "";
    int lenS = S.length();
    int lenL = lenS/2;
    rep(i, lenL){
        L += S[i];
        R += S[i+1+lenL];
    }
    if(solve(S) & solve(L) & solve(R)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main ()
{
  int H, N;
  std::cin >> H >> N;

  for (int i=0; i<N; i++)
    {
      int A;
      std::cin >> A;
      H -= A;
    }

  if (H <= 0) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
}


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

int main()
{

#ifdef _d
    freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
#endif

    int n;
    cin >> n;
    string c;
    cin >> c;
    int i = 0;
    int j = n-1;
    int ans = 0;
    while (true) {
        while (c[i] == 'R') {
            ++i;
        }
        while (c[j] == 'W') {
            --j;
        }
        if (i < j) {
            ++ans;
            ++i;
            --j;
        } else {
            cout << ans << "\n";
            break;
        }
    }

#ifdef _d
    cerr << "Time: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
#endif

    return 0;
}


Measured memory_bytes: 3752
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,lint> pint;
typedef pair<lint,int> pl;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
vector<pint> gr[2][100100];
priority_queue<pl> q;
lint dp[2][100100];bool sumi[2][100100];
lint inf=12345678901234567LL,con=1E15;
void aedge(int id,int x,lint y){
	if(dp[id][x]<=y) return;
	dp[id][x]=y;q.push(mp(-y,x));
}
void cal(int id){
	while(!q.empty()){
		pl p=q.top();q.pop();
		int x=p.se;lint y=-p.fi;
		if(sumi[id][x]) continue;sumi[id][x]=true;
		rep(i,gr[id][x].size()){
			aedge(id,gr[id][x][i].fi,y+gr[id][x][i].se);
		}
	}
}
lint out[100100];
int main()
{
	int n,m,s,t,u,v,a,b;
	cin>>n>>m>>s>>t;
	rep(i,m){
		cin>>u>>v>>a>>b;
		gr[0][u].pb(mp(v,a));
		gr[0][v].pb(mp(u,a));
		gr[1][u].pb(mp(v,b));
		gr[1][v].pb(mp(u,b));
	}
	memset(sumi,false,sizeof(sumi));
	rep(i,100050) dp[0][i]=dp[1][i]=inf;
	aedge(0,s,0);cal(0);
	aedge(1,t,0);cal(1);
	vector<pl> V;REP(i,1,n+1) V.pb(mp(dp[0][i]+dp[1][i],i));
	sort(All(V));
	int it=0;
	rep(i,n){
		if(V[i].se>it){
			REP(j,it,V[i].se) out[j]=V[i].fi;
			it=V[i].se;
		}
	}
	rep(i,n) cout<<con-out[i]<<endl;
}


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

int main() {
    int K, X = 7, count=1;
    cin >> K;
    int N = X % K;
    if(K % 2 == 0 || K % 5 == 0) {
        cout << -1 << endl;
        return 0;
    }


    while(N != 0) {
        N = N * 10 + 7;
        N %= K;
        count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 3628
import java.util.*;

public class Main {

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


    if (n > 1) {
      long[] l = new long[n+1];

      l[0] = 2;
      l[1] = 1;

      for (int i = 2; i < n+1; i++) {
        l[i] = l[i-1]+l[i-2];
      }
      System.out.println(l[n]);
    } else if (n == 0) {
      System.out.println(2);
    } else if (n == 1) {
      System.out.println(1);
    }


  }

}


Measured memory_bytes: 21972
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);
    
    int A, B, C;
    cin >> A >> B >> C;
    swap(A, B);
    swap(A, C);

    cout << A << ' ' << B << ' ' << C << endl;

    return 0;
}


Measured memory_bytes: 256
//BISMILLAH
#include <bits/stdc++.h>
using namespace std;
int main(){
    
    int n,x,t;
    
    cin >> n >> x >> t;
    
    if(n%x == 0) cout << (n/x)*t << endl;
    else cout << ((n/x) + 1) * t << endl;
    
    return 0;
}

Measured memory_bytes: 3564
#include <iostream>
using namespace	std;
int n,g[8][8],r,flag[8];
void check(int now,int how){

  how++;
  flag[now]=1;
  if(how==n) r++;
  for(int i=0;i<n;i++) if(g[now][i]&&flag[i]!=1) check(i,how);
  flag[now]=0;
}
int main(){

  int m,a,b,flag[8]={};

  cin>>n>>m;
  for(int i=0;i<m;i++){
    cin>>a>>b;
    g[a-1][b-1]=1;
    g[b-1][a-1]=1;
  }

  check(0,0);
  cout<<r<<endl;

  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
using ll = long long;
const ll mod = 998244353;
using namespace std;

const int bound = 100000;
ll sp[310][bound];
ll dp[310][bound];

int main(){
	int n;  cin >> n;
	vector<ll> a(n);
	for( auto &k : a ) cin >> k;
	dp[0][0] = 1;
	ll sum = 0;
	ll product = 1;
	for( int i = 0; i < n; ++i ){
		sum += a[i]; sum %= mod;
		product *= 3; product %= mod;
		for( int x = 0; x < bound-500; ++x ){
			dp[i+1][x] += 2*dp[i][x] % mod; dp[i+1][x] %= mod;
			dp[i+1][x+a[i]] += dp[i][x] % mod; dp[i+1][x+a[i]] %= mod;
		}
	}
	ll ngsum = 0;
	for( int x = (sum+1)/2; x < bound; ++x ){
		ngsum += dp[n][x];
		ngsum %= mod;
	}
	if( sum % 2 == 0 ){
		sp[0][0] = 1;
		for( int i = 0; i < n; ++i ){
			for( int x = 0; x < bound-500; ++x ){
				sp[i+1][x] += sp[i][x]; sp[i+1][x] %= mod;
				sp[i+1][x+a[i]] += sp[i][x] % mod; sp[i+1][x+a[i]] %= mod;
			}
		}
	}
	cout << ( product - 3*( ngsum-sp[n][sum/2] ) + 500*mod ) % mod << endl;
}

Measured memory_bytes: 472576
import java.util.Scanner;

public class Main{

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int length = sc.nextInt();
		int times = sc.nextInt();
		String s = sc.next();
		int counter=0;
		String st[] = s.split("");
		int flag =0;
		if(st[0].equals("1") )
			flag=1;
		
		for(int i=0;i<length-1;i++){
			if(!(st[i].equals(st[i+1]))){
				counter++;
			}
		}
		
		int counter2=0;
		int point[] = new int[counter+1];
		int j=0;
		
		for(int i=0;i<length-1;i++){
			if(!(st[i].equals(st[i+1]))){
				point[j] = i-counter2+1;
				counter2 =i+1;
				j++;
			}
		}
		if(j-1 != counter){
			point[j]=length-1-counter2+1;
		}

		int[] cumulativesum = new int[counter+2];
		cumulativesum[0]=0;
		for(int i=1;i<=counter+1;i++)
			cumulativesum[i]=cumulativesum[i-1]+point[i-1];
		
		int max1=-1;
		int max2=-1;
		int k=0;

		if(counter+1>2*times){
			k=2*times;
		}else
			k=counter+1;

		for(int i=0;i+k<counter+2;i++){
			if( (cumulativesum[i+k]-cumulativesum[i]) >max1){
				max1=cumulativesum[i+k]-cumulativesum[i];
			}else {
			}
		}
		
		k=0;

		if(counter+1>2*k+1){
			k=2*times+1;
		}else
			k=counter+1;

		if(flag ==1) {
			for(int i=0;i+k<counter+2;i=i+2){
				if( (cumulativesum[i+k]-cumulativesum[i]) >max2) {
					max2=cumulativesum[i+k]-cumulativesum[i];
				}
			}
		}else {
			for(int i=1;i+k<counter+2;i=i+2){
				if( (cumulativesum[i+k]-cumulativesum[i]) >max2) {
					max2=cumulativesum[i+k]-cumulativesum[i];
				}
			}
		}

		System.out.println(Math.max(max1,max2));
	}
}

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

using namespace std;

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

    vector<int> a1;
    vector<int> a2;

    a1.push_back(0);
    a2.push_back(0);

    for(int i = 1; i < n + 1; i++){
        cin >> t;
        a1.push_back(t + a1[i-1]);
    }
    for(int i = 1; i < n + 1; i++){
        cin >> t;
        a2.push_back(t + a2[i-1]);
    }
    int tmp, ans=0;
    for(int i = 1; i < n + 1; i++){
        tmp = a1[i] + a2[n] - a2[i-1];
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    map<string, lli > ans;
    ans["SUN"]=7;
    ans["MON"]=6;
    ans["TUE"]=5;
    ans["WED"]=4;
    ans["THU"]=3;
    ans["FRI"]=2;
    ans["SAT"]=1;
    string s;
    cin>>s;
    out(ans[s]);
}

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

bool mem[101][100];

int main()
{
loop:
  for(int i = 0; i < 101; i++)
    for(int j = 0; j < 100; j++)
      mem[i][j] = 0;
  int n, m, p;
  cin >> n;
  if(!n)
    return 0;
  for(int i = 0; i < n; i++)
  {
    cin >> m;
    for(int j = 0; j < m; j++)
    {
      cin >> p;
      mem[i][p - 1] = true;
    }
  }
  cin >> m;
  for(int i = 0; i < m; i++)
  {
    cin >> p;
    mem[100][p - 1] = true;
  }
  int ans = -1;
  for(int i = 0; i < n; i++)
  {
    bool b = true;
    for(int j = 0; j < n; j++)
    {
      if(!mem[100][j])
        continue;
      if(!mem[i][j])
        b = false;
    }
    if(b)
    {
      if(ans != -1)
      {
        cout << -1 << endl;
        goto loop;
      }
      ans = i + 1;
    }
  }
  if(ans == -1)
    cout << -1 << endl;
  else
    cout << ans << endl;
  goto loop;
}

Measured memory_bytes: 1168