akhauriyash/Code-Regression huggingface dataset:
#ifndef Local
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
#endif

#include <bits/stdc++.h>

#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

#define popCnt(x) (__builtin_popcountll(x))
#define sz(x) ((int)(x.size()))
#define all(v) begin(v), end(v)
typedef long long Long;
typedef long double Double;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#else
#define endl '\n'
#endif

  Long a;
  Double b;
  cin >> a >> b;

  cout << Long(a * b) << endl;

  return 0;
}

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


int main() {

  int n;
  cin >> n;

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

  int q;
  cin >> q;

  while(0 < q) {

    int b, e, k;
    cin >> b >> e >> k;

    int ans = 0;

    for (int i = b; i < e; i++) {
      if (a[i] == k) {
        ans++;
      }
    }

    cout << ans << endl;

    q--;

  }
  
  return 0;

}


Measured memory_bytes: 3104
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
#define fst first
#define snd second
using ll = long long;
using I = pair<int, int>;

int func(int n, int k) {
  --k;
  return (max(0, n) + k - 1) / k;
}

int main() {
  int N, K;
  while (cin >> N >> K) {
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    int mn;
    for (int i = 0; i < N; i++) {
      if (A[i] == 1) {
        mn = i;
        break;
      }
    }
    int L = mn, R = N - mn - 1;
    int res = 1 << 30;
    for (int i = 0; i < K; i++) {
      int j = K - 1 - i;
      int cost = 1 + func(L - i, K) + func(R - j, K);
      res = min(res, cost);
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (binary me 1 kitne hai) (if longlong popcount ll)
#define ln "\n"
#define dbg(x) cerr<<#x<<" = "<<x<<endl
#define dbg2(x,y) cerr<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;
#define dbgstl32(v) cerr<<#v<<" = \n"; { int c=0; forstl(it,v) \
cerr<<"    Term "<< ++c <<" = "<<it<<ln;} cerr<<endl
#define dbgstlp32(v) cerr<<#v<<" = \n"; { int c=0; forstl(it,v) \
cerr<<"    Term "<< ++c <<" = "<<it.fi<<" , "<<it.se<<ln;} cerr<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(n) n.begin() , n.end() 
#define tfi first.first
#define tse first.second
#define tth second
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
typedef pair< pair<int,int> , int> tri;

#pragma GCC optimize ("-O2")
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); }
const int LIM = 2e5+5 ,MOD = 1e9+7;

const ll inf = 10000000000;
//int n , m , t , x ,y ;
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

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

	ll h[n+1];
	forn(i,n) cin >> h[i+1];

	ll cost[n+1];
	forn(i,n) cost[i+1]=inf;
	cost[1]=0;

	for(int i=1; i<=n; i++){
		for(int j=i+1; j-i<=k && j<=n; j++){
			cost[j]=min(cost[i]+abs(h[i]-h[j]), cost[j]);
		}
	}

	cout << cost[n];

}

Measured memory_bytes: 1792
#include <stdio.h>
#include <ctype.h>

int main(void){
	int a, b, i;
	bool f = true;
	char c;
	scanf("%d %d", &a, &b);
	scanf("%c", &c);
	for(i = 0;i <= a + b;++i){
		scanf("%c", &c);
		if(i == a){
			if(c != '-'){
				f = false;
			}
		}else if(!isdigit(c)){
			f = false;
		}
	}

	if(f){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

	return 0;
}

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

int main(int argc, char *argv[]){
  int suma = 0, sumb = 0;
  int tmp;
  for (int i = 0; i < 4; i++) {
    cin >> tmp;
    suma += tmp;
  }
  for (int i = 0; i < 4; i++) {
    cin >> tmp;
    sumb += tmp;
  }

  if(suma > sumb){
    std::cout << suma << std::endl;
  }else{
    std::cout << sumb << std::endl;    
  }

  return 0;
}

Measured memory_bytes: 1164
#include <iostream>
using namespace std;
int main() {
  int N, K, R, S, P;
  std::string T;
  cin >> N >> K >> R >> S >> P >> T;
  int score = 0;
  std::string hands;
  std::string flg;
  for(int i=0;i<N;i++) {
    if(T.substr(i,1) == "r") {
        if(i >= K && hands.substr(i-K,1) == "p") {
            hands += "z";
        }else{
            score += P;
            hands += "p";
        }
    }else if(T.substr(i,1) == "s") {
        if(i >= K && hands.substr(i-K,1) == "r") {
            hands += "z";
        }else{
            score += R;
            hands += "r";
        }
    }else if(T.substr(i,1) == "p") {
        if(i >= K && hands.substr(i-K,1) == "s") {
            hands += "z";
        }else{
            score += S;
            hands += "s";
        }
    }
  }
  cout << score << endl;
}

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

int main(){
  int n,y,m,d,o,i,j,k,sum;
  cin >> n;
  for(o=0;o<n;o++){
    cin >> y >> m >> d;
    sum=0;
    i=y;j=m;k=d;
    while(i!=1000){
      sum++;
      k++;
      if(i%3!=0&&j%2==0){
	if(k==20){
	  j++;
	  k=1;
	}
      }else if(k==21) {
	k=1;
	j++;
      }

      if(j==11) {
	j=1;
	i++;
      }
    }
    cout << sum << endl;
  }
  return 0;
}

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

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    
    vector<int> nums(n,1),can(n,0);
    can[0] = 1;
    
    for (int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        
        a--, b--;
        
        if (can[a]) can[b] = 1;
        if (nums[a] == 1) can[a] = 0;
        nums[a]--;
        nums[b]++;
    }
    int res = 0;
    for (int i = 0; i < n; i++){
        if (can[i] && nums[i])res++;
    }
    
    cout << res << endl;
}

Measured memory_bytes: 4028
import sys
input = lambda: sys.stdin.readline().strip("\r\n")

n, k = map(int, input().split())
mod = 10**9 + 7
ans = 0
for i in range(k, n+2):
    mini = i*(i+1)//2
    maxi = (n+1)*(n+2)//2 - (n+1-i)*(n+1-i+1)//2
    ans += maxi - mini + 1
print(ans % mod)


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

int main() {
  int n, a, counter = 0, min;
  cin >> n;
  min = 10000;
  for (int i = 0; i<n; i++){
    counter = 0;
    cin >> a;
    while(a%2 ==0){
      counter++;
      a /= 2;
      if (counter > min){
        break;
      }
    }
    if (min > counter){
      min = counter;
    }
  }
  cout << min << endl;
}


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

int main() {
  int a;
  string b;
  cin>>a>>b;
  if(a<b.size()){
    for(int i=0;i<a;i++){
      cout<<b.at(i);
    }
    cout<<"..."<<endl;
  }
  else{
    cout<<b<<endl;
  }
}

Measured memory_bytes: 3580
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF 1 << 30
#define MAX 1000000000

ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }

int main() {
	int N;
	scanf("%d", &N);
	vector<int> X(N), L(N), n(N, 0);
	vector<pair<int, int>> q(N);
	rep(i, 0, N) {
		scanf("%d%d", &X[i], &L[i]);
		q[i].second = X[i] - L[i];
		q[i].first = X[i] + L[i];
	}
	sort(all(q));
	int c = 0, ans = 1, f = 1;
	while (f) {
		f = 0;
		rep(i, c + 1, N) {
			if (q[i].second < q[c].first)continue;
			c = i;
			ans++;
			f = 1;
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

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

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    cin >> x;
    int p = x / 500;
    cout << p * 1000 + (x % 500) / 5 * 5 << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map>
#include <string>
#include <bits/stdc++.h>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;

static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;
using pint = pair<int,int>;


int main(){
  ll n,k;
  cin >> n >> k;
  string s;
  cin >> s;

  ll res = 0;

  //"RL"
  REP(i,s.size()-1)
  {
    if(s[i] == s[i+1])++res;
  }
  res = min(n-1, res + 2 * k);
  cout << res <<  endl;
  return 0;
}



Measured memory_bytes: 512
import java.util.Scanner;

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

		if (a > b) {
			System.out.println("a" + " > " + "b");
		} else if (a < b) {
			System.out.println("a" + " < " + "b");
		} else {
			System.out.println("a" + " == " + "b");
		}
	}
}

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

int main()
{
	int t,mc=0;
	map<int,int> m;
	while(cin >> t)
	{
		if(!(m.insert(pair<int,int>(t,1)).second))
		{
			m[t]++;
		}
		mc = (m[t]>mc ? m[t] : mc);
	}
	
	map<int,int>::iterator it;
	for(it=m.begin(); it!=m.end(); it++)
	{
		if(mc==it->second)
		{
			cout << it->first << endl;
		}
	}
}

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

typedef long long LL;

const int N=200000;

int n;
LL a[N*2+9],b[N*2+9];

void into(){
  scanf("%d",&n);
  for (int i=1;i<=n;++i)
	scanf("%lld",&a[i]);
  for (int i=1;i<=n;++i)
	scanf("%lld",&b[i]);
}

void Get_ab(){
  int mx=1;
  for (int i=1;i<=n;++i)
	if (a[i]>a[mx]) mx=i;
  for (int i=1;i<mx;++i) a[i+n]=a[i],b[i+n]=b[i];
  for (int i=1;i<=n;++i) a[i]=a[mx+i-1],b[i]=b[mx+i-1];
  a[++n]=a[1];b[n]=b[1];
}

LL dp[N+9];

void Get_dp(){
  dp[1]=dp[2]=0;
  for (int i=3;i<=n;++i) a[i]-=dp[i]=(b[i-1]+dp[i-1]<<1)-dp[i-2];
}

int p[N+9],cp;

void Get_p(){
  p[cp=1]=1;
  for (int i=2;i<=n;++i){
	for (;cp>1&&(a[i]-a[p[cp]])*(p[cp]-p[cp-1])>=(a[p[cp]]-a[p[cp-1]])*(i-p[cp]);--cp);
	p[++cp]=i;
  }
}

LL ans;

void Get_ans(){
  for (int i=1;i<cp;++i) ans+=(a[p[i]]+a[p[i+1]])*(p[i+1]-p[i]+1)-a[p[i+1]]*2;
  for (int i=1;i<n;++i) ans+=dp[i]<<1;
}

void work(){
  Get_ab();
  Get_dp();
  Get_p();
  Get_ans();
}

void outo(){
  printf("%.12lf\n",1.0*ans/2/(n-1));
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 11476
#include <iostream>
using namespace std;
int search(int a[],int N,int key)
{
    int i=0;
    a[N]=key;
    while(a[i]!=key) i++;
    return i!=N;
}
int main()
{
    int a[10000],n,q;
    int num=0,data;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    cin>>q;
    while(q--){
        cin>>data;
        if(search(a,n,data)){num++;}
        }
    cout<<num<<endl;
    return 0;
}



Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vec;
int main(){
  int n;cin>>n;
  vec A(n),B(n-1);
  rep(i,n-1) cin>>B[i];
  A[0]=B[0];
  A[n-1]=B[n-2];  
  for(int i=1;i<n-1;i++) A[i]=min(B[i],B[i-1]);
  int ans=0;
  rep(i,n) ans+=A[i];
  cout<<ans;
}

Measured memory_bytes: 256
n=int(input())
List=list(map(int,input().split()))

arr = [0,0,0]
ans = 1
MOD = 1000000007

for i in range(len(List)):
  a = List[i]
  
  b = arr.count(a)
  
  if b > 0:
    j = arr.index(a)
    arr[j] = a + 1
    
    ans = ans * b
    
  else:
    ans = 0
    break
    
print(ans%MOD)

Measured memory_bytes: 14020
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

vector<int> ps = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};

int howmany(int x, int y) {
  int c=0;
  while(x%y==0) {
    c++;
    x/=y;
  }
  return c;
}

bool check(vector<int>& freq, int n) {
  int k=ps.size();
  rep(i,k) {
    int c=0;
    repeat(j,1,n+1) {
      c+=howmany(j,ps[i]);
    }
    if(freq[i]>c)
      return false;
  }
  return true;
}

int rec(int s, int k, vector<int>& freq, int n) {
  if(s==freq.size()) {
    if(k!=1)
      return 0;
    if(check(freq,n))
      return 1;
    else
      return 0;
  }
  int ret=0;
  repeat(i,1,k+1) {
    if(k%i==0) {
      int prev=freq[s];
      freq[s]=i-1;
      ret+=rec(s+1,k/i,freq,n);
      freq[s]=prev;
    }
  }
  return ret;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n;
  cin>>n;
  vector<int> freq(ps.size());
  cout << rec(0,75,freq,n) << endl;
  return 0;
}


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

using namespace std;

int main() {
	int N, L;
	cin >> N >> L;
	vector<string> s(N);
	for (int i = 0; i < N; i++) {
		cin >> s[i];
	}

	sort(s.begin(), s.end());
	for (int i = 0; i < N; i++) {
		cout << s[i];
	}

	cout << endl;
	return 0;
}


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

int main(){

    int n, count=0; cin >> n;
    string s; cin >> s;

    for (int i=0;i<n;i++){

        if (s[i]=='O' && s[i+1]=='X' || s[i]=='X' && s[i+1]=='O'){
            count += 1;
            i += 1;
        }

    }

    cout << count << endl;
}



Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long N,M;
  cin>>N>>M;
  vector<vector<long long>>G(N);
  vector<set<long long>>K(N);
  for(int i=0;i<M;i++){
    long long a,b;
    cin>>a>>b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
    K[a].insert(b);
    K[b].insert(a);
  }
  bool flag=false;
  if(G[0].size()>0&&G[N-1].size()>0){
    for(int i=0;i<G[0].size();i++){
      if(K[N-1].count(G[0][i])){
        flag=true;
      }
    }
  }
  if(flag){
    cout<<"POSSIBLE"<<endl;
  }
  else{
    cout<<"IMPOSSIBLE"<<endl;
  }
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> votes;
    double sum = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        votes.push_back(a);
        sum += a;
    }
    int j = 0;
    double cutoff = sum / (4*m);
    for (int i = 0; i < n; i++) {
        if (votes[i] >= cutoff) j++;
    }
    if (j >= m) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}


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

int main(){
	int n;
	cin>>n;
	map<string, int> count;
	while(n--){
		string s;
		cin>>s;
		if(count.empty()){
			count.insert(pair<string,int>(s,0));
		}else{
			map<string, int>::iterator it = count.find(s);
			if(it == count.end()){
				count.insert(pair<string,int>(s,0));
			}else{
				it->second++;
			}
		}
	}
	cout<<count.size()<<endl;
	return 0;
}

Measured memory_bytes: 19116
#include <cstdio>

const int N=100005;
typedef long long LL;

LL a[N*3],b[N*3];
int x[N],w[N],ans[N];

int main(){
	int n,L,T;
	scanf("%d%d%d\n",&n,&L,&T);
	LL p=T/L*2,q=T%L*2,ta=0,tb=0;
	for (int i=0;i<n;i++){
		scanf("%d%d\n",&x[i],&w[i]);
		if (w[i]==1) a[++ta]=x[i];
			else b[++tb]=x[i];
	}
	for (int i=1;i<=ta;i++){
		a[i]-=L*2;
		a[i+ta]=a[i]+L;
		a[i+ta*2]=a[i]+L*2;
	}
	for (int i=1;i<=tb;i++){
		b[i+tb]=b[i]+L;
		b[i+tb*2]=b[i]+L*2;
	}
	for (int i=0,l=1,r=1;i<n;i++)
	if (w[i]==1){
		for (;l<=tb*3 && b[l]<=x[i];l++);
		for (;r<=tb*3 && b[r]<x[i]+q;r++);
		ans[(r-l+p*tb+i)%n]=(x[i]+T)%L;
	}
	for (int i=0,l=1,r=1;i<n;i++)
	if (w[i]==2){
		for (;l<=ta*3 && a[l]<=x[i]-q;l++);
		for (;r<=ta*3 && a[r]<x[i];r++);
		ans[((i-r+l-p*ta)%n+n)%n]=(x[i]-T%L+L)%L;
	}
	for (int i=0;i<n;i++) printf("%d\n",ans[i]);
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

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

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	int h,w;
	cin>>h>>w;
	vector<vector<char>> a(h+1,vector<char>(w+1,0));
	rep(i,h)rep(j,w)cin>>a[i+1][j+1];
	vector<vector<ll>> dp(h+1,vector<ll>(w+1,0));
	dp[1][1]=1;
	repi(i,1,h+1)repi(j,1,w+1){
		if(a[i][j]=='#')continue;
		if(i==1&&j==1)continue;
		dp[i][j] = dp[i-1][j] + dp[i][j-1];
		dp[i][j] %= mod;
	}
	cout<<dp[h][w]<<endl;

	return 0;
}

Measured memory_bytes: 12128
#include<stdio.h>

int lo(int n);

int main(void)
{
	int N, A, B;
	int i;
	int total = 0;
	int sum;

	(void)scanf("%d%d%d", &N, &A, &B);

	for (i = 0; i <= N; i++) {
		sum = lo(i);
		if (sum >= A && sum <= B) {
			total += i;
		}
	}

	printf("%d", total);
	return 0;
}

int lo(int n) {
	int sum = 0;
	while (n > 0) {
		sum += n % 10;
		n /= 10;
	}

	return sum;
}

Measured memory_bytes: 1684
S=input()
T=S[:(len(S)-1)//2]
U=S[(len(S)+3)//2-1:]
if S==S[::-1]:
    if T==T[::-1]:
        if U==U[::-1]:
            print('Yes')
        else:print('No')
    else:print('No')
else:print('No')

Measured memory_bytes: 9136
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <climits>
#include <numeric>
#include <math.h>
#define ll long long
#define INF INT_MAX 
using namespace std;
int main(){
	ll N;
	cin >> N;
	N=N*2;
	ll L[N];
	for(int i=0;i<N;i++){
		cin >> L[i];
	}
	sort(L,L+N);
	ll ans=0;
	for(int i=0;i<N;i++){
		if(i%2==0){
			ans = ans+L[i];
		}
	}
	cout << ans << endl;
}

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

int main() {
 int N,A=0;
  string S;
  cin>>N>>S;
  vector<int> p(N);
  vector<int> q(N);
  for(int i=N-1;i>=0;i--){
    if(S[i]=='1'){
      A++;
    }
  }
  int Q=A-1,W=A+1;
  int X=0,Y=0,E=1,R=1;
  for(int i=N-1;i>=0;i--){
    p[i]=E;
    q[i]=R;
    if(S[i]=='1'){
      X+=p[i];
      Y+=q[i];
      if(Q!=0){
        X%=Q;
      }
      Y%=W;
    }
    E*=2;
    if(Q!=0){
      E%=Q;
    }
    R*=2;
    R%=W;
  }
  for(int i=0;i<N;i++){
    int b,Z=1;
    if(A==1&&S[i]=='1'){
      cout<<"0"<<endl;
      continue;
    }
      if(S[i]=='1'){
      b=(X-p[i]+Q)%Q;
    }
    else{
      b=(Y+q[i])%W;
    }
    while(b!=0){
      int D=b,T=1,P=0;
      while(D!=0){
        if(D%(T*2)!=0){
          D-=T;
          P++;
        }
        T*=2;
      }
      b%=P;
      Z++;
    }
    cout<<Z<<endl;
  } 
}

Measured memory_bytes: 5240
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int arr[3],a=0,b=0;
  for(int i=0;i<3;i++)
  {
    cin>>arr[i];
  }
for(int i=0;i<3;i++)
{
  if(arr[i]==5)
     a++;
     else if(arr[i]==7)
     b++;
     }
     if(a==2&&b==1)
     cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const ll mod=1000000007;

int main(void){
    ll n,q,a[100001],sum=0,p[100001]={};
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        p[a[i]]++;
        sum+=a[i];
    }
    cin>>q;
    for(int i=0;i<q;i++){
        ll b,c;
        cin>>b>>c;
        sum-=(b*p[b]+c*p[c]);
        p[c]+=p[b];
        sum+=c*p[c];
        p[b]=0;
        printf("%lld\n",sum);
    }
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/24  Problem: code-festival-2017-final_b / Link: https://cf17-final.contest.atcoder.jp/tasks/cf17_final_b?lang=en  ----- */
/* ------問題------

すぬけ君は a、b、c の 3 種類の文字のみからなる文字列 S を持っています。
回文恐怖症のすぬけ君は S の文字を自由に並び替えて、2 文字以上の回文を部分文字列として含まないようにしようと思いました。 これが可能かどうかを判定して下さい。

-----問題ここまで----- */
/* -----解説等-----

順番はなんでもいいけどabcabcabc...しかつくれない。
したがってアルファベットのそれぞれの個数についてMax-Min<=1のみ作成可能
あとはつくれない

----解説ここまで---- */

LL N;

LL ans = 0LL;

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


	string s;
	cin >> s;

	VI a(3, 0);
	FOR(i, 0, SZ(s)) {
		a[s[i] - 'a']++;
	}
	int m = INF;
	int M =- INF;
	FOR(i, 0, 3) {
		M = max(M, a[i]);
		m = min(m, a[i]);
	}
	if (M - m < 2) {
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 512
n,a=map(int, input().split())
x=list(map(int, input().split()))

dp=[[[0]*(2550) for _ in range(55)] for _ in range(55)]
dp[0][0][0]=1
for i in range(n):
    for j in range(n+1):
        for sm in range(n*a+1):
            if dp[i][j][sm]==0:
                continue
            dp[i+1][j][sm]+=dp[i][j][sm]
            dp[i+1][j+1][sm+x[i]]+=dp[i][j][sm]

ans=0
for k in range(1,n+1):
    ans+=dp[n][k][a*k]
print(ans)


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

int main()
{string s;
cin>>s;
int i,d=0,c=0;
for(i=0;i<s.size();i++){
    if(s[i]=='R'){
        c++;
      d=c;
    }
    if(s[i]=='S'){
        c=0;
    }
}
cout<<d;
    return 0;
}


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

const int N = 2e5 + 5;
const int INF = 0x3f3f3f3f;
int d[2][N][32], a[2][N], pos[N];

void RMQ_init(int n, int v) {
    for(int i = 0; i < n; i++) d[v][i][0] = a[v][i];
    for(int j = 1; (1 << j) <= n; j++)
        for(int i = 0; i + (1 << j) - 1 < n; i++)
            d[v][i][j] = min(d[v][i][j - 1], d[v][i + (1 << (j - 1))][j - 1]);
}

int RMQ(int L, int R, int v) {
    int k = 0;
    while((1 << (k + 1)) <= R - L + 1) k ++;
    return min(d[v][L][k], d[v][R - (1 << k) + 1][k]);
}

struct node {
    int x, L, R;
    bool operator < (const node& A) const {
        return x > A.x;
    }
};

int main() {
    int n, x;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf("%d", &x);
        a[i & 1][i] = x;
        a[(i & 1) ^ 1][i] = INF;
        pos[x] = i;
    }
    RMQ_init(n, 0); RMQ_init(n, 1);
    priority_queue<node> Q;
    x = RMQ(0, n - 1, 0);
    Q.push({x, 0, n - 1});
    while(!Q.empty()) {
        node x = Q.top(); Q.pop();
        int v1 = x.x, v2 = RMQ(pos[x.x] + 1, x.R, (pos[x.x] & 1) ^ 1);
        printf("%d %d ", v1, v2);
        v1 = pos[v1], v2 = pos[v2];
        if(x.L != v1) Q.push({RMQ(x.L, v1 - 1, x.L & 1), x.L, v1 - 1});
        if(v1 + 1 != v2) Q.push({RMQ(v1 + 1, v2 - 1, (v1 + 1) & 1), v1 + 1, v2 - 1});
        if(v2 != x.R) Q.push({RMQ(v2 + 1, x.R, (v2 + 1) & 1), v2 + 1, x.R});
    }
    return 0;
}

Measured memory_bytes: 54392
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  int64_t r = 0, g = 0, b = 0;
  
  for(int i = 0; i < N; i++){
    if(S[i] == 'R')
      r++;
    else if(S[i] == 'G')
      g++;
    else
      b++;
  }
  
  int64_t ans = r*g*b;
  
  for(int i = 0; i < N-2; i++){
    for(int j = i+1; j < N-1; j++){
      int k = 2*j - i;
      if(k < N && S[i] != S[j] && S[j] != S[k] && S[i] != S[k])
        ans--;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<iomanip>
using namespace std;


int main(){
    int n,q;
    cin >> n >> q;
    string s;
    cin >> s;
    int d[n];
    d[0] = 0;
    for (int i = 1; i < n; i++){
        if (s[i] == 'C' && s[i-1] == 'A'){
            d[i] = d[i-1]+1;
        }
        else d[i] = d[i-1];
    }

    int l[q],r[q];
    for (int i = 0; i < q; i++){
        cin >> l[i] >> r[i];
    }
    for (int i = 0; i < q; i++){
        cout << d[r[i]-1] - d[l[i]-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N; cin>>N;
	vl L(N+1); L[0] = 2; L[1] = 1;
	rp(i, 2, N+1) L[i] = L[i-1] + L[i-2];
	cout<< L[N] <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,ll>
const ll MOD=998244353;
const int INF=1e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    repr(i,n,n+100000) {
        int k=i%10;
        int j=i;
        while (j>0) {
            if (j%10!=k) break;
            j/=10;
        }
        if (j==0) {
            cout << i << endl;
            break;
        }
    }

}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;

int main(){  
  string s;
  cin >> s;
  cout << (s.rfind("Z")-s.find("A"))+1 << endl;
  return 0;
}

Measured memory_bytes: 640
#![allow(non_snake_case, unused_imports)]

// Input
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)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $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, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        S: chars,
    }
    let mut ans = 0;
    let mut v = vec![false; 10];
    for i in 0..S.len(){
        if "ACGT".contains(S[i]){
            v[i] = true;
        } 
    }
    let mut cnt = 0;
    for i in 0..S.len(){
        if v[i]{
            cnt += 1;
            ans = max(ans,cnt);
        }else{
            cnt = 0;
        }
    }
    println!("{}",ans);
}

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

int main() {
    int n;cin>>n;
    int n2 = n%1000;
    int ans = (1000 - n2)%1000;
    cout<<ans<<endl;
	return 0;
}

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

int main()
{
  long long int m,rd,rr,cd,cr;
  bool flag=true;
  for(;cin>>m>>rd>>rr>>cd>>cr;)
    {
      long long int d,r,x;
     
      x=ceil(cd*100.0/rd);
      d=(rd*x/100)-cd;
      //      cout<<"x:"<<x<<endl;
      //      cout<<"d:"<<d<<endl;
      m-=x;
      if(m<0)
	flag=false;
      m+=floor(100.0*d/rd);

      x=ceil(cr*100.0/rr);
      r=(rr*x/100)-cr;
      //      cout<<"x:"<<x<<endl;
      //      cout<<"d:"<<d<<endl;
      m-=x;
      if(m<0)
	flag=false;
      m+=floor(100.0*r/rr);
      
      if(!flag)
	m=-1;
      
      cout<<m<<endl;
	
    }

}

Measured memory_bytes: 1164
N = int(input())
A = list(map(int, input().split()))

if __name__ == '__main__':
    flg = True
    cnt = 0
    while flg:
        for i in range(N):
            flg = False
            for j in range(N-1, i, -1):
                if A[j] < A[j-1]:
                    A[j], A[j-1] = A[j-1], A[j]
                    cnt += 1
                    flg = True
    print(" ".join(map(str, A)))
    print(cnt)


Measured memory_bytes: 5600
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vit vector<lint>::iterator
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define graph_set(n) struct edge{int to,int cost;} vector<edge> G((n))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define range(x,y) ((x) >= 0 && (x) < h && (y) >= 0 && (y) < w)
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
typedef vector<long long> vi;
typedef vector<pair<long long, long long>> vp;
typedef vector<vector<long long>> vvi;
typedef pair<long long, long long> pi;
typedef long long lint;
typedef long long ll;
lint qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e14;

//////////////////////////////////////////////////////////////////////
int x[10][10];
int main(void) {
	ll n; cin >> n;
	vi a(n); rep(n)cin >> a[i];
	vi x(n,0);
	int d = 1;
	for (int i = n - 1; i >= 0; i--) {
		x[0] += d * a[i];
		d *= -1;
	}

	for (int i = 1; i < n; i++) {
		x[i] = 2 * a[i - 1] - x[i - 1];
	}
	rep(n) cout << x[i] << " ";
	return 0;
}

Measured memory_bytes: 2944
import java.util.Arrays;
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int n = sc.nextInt();
    int[] arr = new int[n];
    int sum = 0; boolean flag = true;
    for(int i=0;i<n;i++) {
      arr[i]=sc.nextInt();
      sum = sum + arr[i];
    }
    String ans = (sum>=h) ? "Yes" : "No";
    System.out.println(ans);


    }
  }


Measured memory_bytes: 48840
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#define MOD 1000000007
using namespace std;
typedef long long ll;
const int inv2 = 500000004;

template <typename Tp> inline void getint(Tp &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

inline int tasu(int a, const int &b) {return (a += b) >= MOD ? a - MOD : a;}

inline ll fastpow(ll bas, ll ex){
	register ll res = 1; bas %= MOD;
	for(; ex; ex >>= 1, bas = bas * bas % MOD) if(ex & 1) res = res * bas % MOD;
	return res;
}

int B, W, N, ibin[200005] = {1}, fac[200005] = {1}, ifac[200005], f[200005], g[200005];

inline ll C(const int &n, const int &m) {return fac[n] * (ll)ifac[m] % MOD * ifac[n - m] % MOD;}

int main(){
	getint(B), getint(W), N = B + W;
	for(register int i = 1; i <= N; i++) ibin[i] = ibin[i - 1] * (ll)inv2 % MOD;
	for(register int i = 1; i <= N; i++) fac[i] = fac[i - 1] * (ll)i % MOD;
	ifac[N] = fastpow(fac[N], MOD - 2);
	for(register int i = N; i >= 1; i--) ifac[i - 1] = ifac[i] * (ll)i % MOD;
	for(register int i = 1; i <= N; i++){
		printf("%lld\n", tasu((1LL + MOD - f[i - 1] + MOD - g[i - 1]) * inv2 % MOD, g[i - 1]));
		f[i] = tasu(f[i - 1], C(i - 1, B - 1) * (ll)ibin[i] % MOD);
		g[i] = tasu(g[i - 1], C(i - 1, W - 1) * (ll)ibin[i] % MOD);
	}
	return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,x,n) for (int i = x; i < n; i++)
using ll = long long int;
int main() {
    int n; cin >> n;
    ll ans=0;
    rep2(i,1,n){
        int I = i;
        for (int j=1;j*j<=I;j++) {
            if(I%j==0) ans+=2;
            if(j*j==I) ans-=1;
        }
    }
    cout << ans << endl;
    return 0;
}

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


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

	int k;
	if ((a + b) % 2 == 0) {
		cout << (a + b) / 2 << endl;
	} else {
		cout << "IMPOSSIBLE" << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#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 SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	string S, T;
	cin >> S >> T;

	int ans = 0;
	REP(i, 3) {
		if (S[i] == T[i])ans++;
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <string>
#include <set>
#include <map>

using namespace std;

const int mod = 1e9 + 7;

int dp[5001];
int dp2[5001];

int add(int x, int y) {
	x += y;
	if (x >= mod) {
		x -= mod;
	}
	return x;
}

void upd(int &x, int y) {
	x += y;
	if (x >= mod) {
		x -= mod;
	}
}

int main() {
	int n, K;
	cin >> n >> K;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	dp[0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = K - 1; j >= a[i]; j--) {
			upd(dp[j], dp[j - a[i]]);
		}
	}
	// dp[i+1][j] = dp[i][j-a[i]]+dp[i][j]
	// dp[i][j]=dp[i+1][j]-dp[i][j-a[i]]
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < min(K, a[i]); j++) {
			dp2[j] = dp[j];
		}
		for (int j = a[i]; j < K; j++) {
			dp2[j] = add(dp[j], mod - dp2[j - a[i]]);
		}
		bool any = false;
		for (int j = 0; j < K; j++) {
			if (dp2[j] != 0 && j + a[i] >= K) {
				any = true;
			}
		}
		if (!any) {
			ans++;
		}
	}
	cout << ans << endl;
}

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

using namespace std;

int main()
{
    char s[1000];

    int Ans, ans;

    Ans = 0, ans = 0;

    scanf("%s", s + 1);

    int len = strlen(s + 1);

    for (int i = 1; i <= len; ++ i)
    {
        if (s[i] == 'R')
                ans ++;
        else ans = 0;

        Ans = max(ans, Ans);
    }

    cout << Ans;
}

Measured memory_bytes: 3800
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <sstream>
#include <math.h>
using namespace std;
//for (int i = 0; i < N; i++){}

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

    int res = 0;
    for(int i=0;i<S.size()-1;i++){
//        cout << S[i] << "-" << S[i+1] << endl;
        if(S[i] != S[i+1]){
//            S[i+1] = S[i];
            res++;
        }
    }
    cout << res << endl;
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

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

    string s;
    cin >> s;
    int ans = 0;
    REP(i, s.size() / 2) {
        if(s[i] != s[s.size() - 1 - i]) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int A,B,C,D;
    scanf("%d %d %d %d",&A,&B,&C,&D);
    A=A*B;
    C=C*D;
    if(A>C){
            printf("%d",A);

    }
    else  if(C>A){
        printf("%d",C);
    }
    else if(A=C){
        printf("%d",A);
    }
    else {
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int size = n;
		int [][]graph = new int[size][size];
		
		
		for(int i = size; i > 0; i--) {
			int j = sc.nextInt() -1;
			int k = sc.nextInt();
		
			while(k-- > 0) {
			graph[j][sc.nextInt() - 1]++;
			}
		}
		for(int i = 0; i < size; i ++) {
			System.out.print(graph[i][0]);
			for(int j = 1; j < graph[i].length; j++) {
					System.out.print( " " + graph[i][j]);
					
				
			}
			System.out.println();
		}
	}
}



Measured memory_bytes: 31516
import java.util.Scanner;


public class Main{
	public static void main(String[] args){
    	int m,f,r;

    	Scanner sc = new Scanner(System.in);

    	while(true){
    		m = sc.nextInt();
    		f = sc.nextInt();
    		r = sc.nextInt();

    		if(m == -1 && f == -1 && r == -1){
    			break;
    		}

    		if(m == -1 || f == -1 || m+f < 30){
    			System.out.println("F");
    		}
    		else if(m+f >= 80){
    			System.out.println("A");
    		}
    		else if(m+f >= 65){
    			System.out.println("B");
    		}
    		else if(m+f >=50 || r >= 50){
    			System.out.println("C");
    		}
    		else{
    			System.out.println("D");
    		}
    	}
    }
}

Measured memory_bytes: 26396
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

//Molecular Formula
public class Main{

	char[] s;
	int id;
	char get(){
		return s[id++];
	}
	
	Map<String, Integer> ref;
	
	int mol(){
		int res = 0;
		for(;;){
			char ch = get();
			if(ch=='('){
				int x = mol();
				if(x==-1)return -1;
				res+=x*num();
			}
			else if(Character.isUpperCase(ch)){
				id--;
				int a = atom();
				if(a==-1)return -1;
				if(Character.isDigit(s[id]))res+=a*num();
				else res+=a;
			}
			else break;
		}
		return res;
	}
	int atom(){
		String res = get()+"";
		if(Character.isLowerCase(s[id]))res+=get();
		return ref.containsKey(res)?ref.get(res):-1;
	}
	int num(){
		int x = get()-'0';
		if(Character.isDigit(s[id]))x=x*10+get()-'0';
		return x;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		ref = new HashMap<String, Integer>();
		for(;;){
			String x = sc.next();
			if("END_OF_FIRST_PART".equals(x))break;
			ref.put(x, sc.nextInt());
		}
		for(;;){
			s = (sc.next()+"$").toCharArray();
			if(s[0]=='0')break;
			id = 0;
			int r = mol();
			System.out.println(r==-1?"UNKNOWN":r);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
import sys
from collections import deque

n, m = map(int, input().split())
link = [ [] for i in range(n)]
for i in sys.stdin.readlines():
    a, b = map(int, i.split())
    link[a-1].append(b-1)
    link[b-1].append(a-1)

d = deque([0])
ans = [-1]*n
ans[0] = 0
while d:
    p = d.popleft()
    for v in link[p]:
        if ans[v] == -1:
            ans[v] = p+1
            d.append(v)

if -1 in ans:
    print("No")
else:
    print("Yes")
    print("\n".join(map(str, ans[1:])))


Measured memory_bytes: 47332
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		solve();
	}

	private static final void solve() {
		try (Scanner cin = new Scanner(System.in)) {
			int length = cin.nextInt();
			int[] array = new int[length];
			int ans = 0;

			for (int i = 0; i < length; i++) {
				array[i] = cin.nextInt();
			}

			try {
				for (int i = 0; i < length; i++) {
					if (array[i] == i + 1) {
						ans++;
						if (array[i + 1] == i + 2) {
							i++;
						}
					}
				}
			} catch (ArrayIndexOutOfBoundsException e) {
			}

			System.out.println(ans);
		} finally {
		}
	}

}


Measured memory_bytes: 50732
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+7;
int n,m;
int h[maxn],a,b;
int ans=0;
vector<int> v[maxn];
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>h[i];
    for(int i=0;i<m;i++){
        cin>>a>>b;
        v[a].push_back(h[b]);
        v[b].push_back(h[a]);
    }
    for(int i=1;i<=n;i++){
        int len=v[i].size();
        if(len==0) ans++;
        else{
            sort(v[i].rbegin(),v[i].rend());
            if(h[i]>v[i][0]) ans++;
        }
    }
    cout<<ans;
    return 0;
}


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

int T, N;
int t[35], ivs[110];
int dp[110][110];

const int D = 100;
const int INF = 1 << 30;

void chmin(int &a, int b) {
    a = min(a, b);
}

int main() {
    while(cin >> T, T) {
        for(int i=0; i<T; i++) cin >> t[i];

        cin >> N;
        fill(ivs, ivs + D + 1, 24);
        for(int i=0; i<N; i++) {
            int day; cin >> day;
            int tim; cin >> tim;
            chmin(ivs[day], tim);
        }

        for(int i=0; i<=D; i++) {
            for(int j=0; j<=D; j++) {
                dp[i][j] = INF;
            }
        }

        dp[0][0] = 0;
        for(int i=1; i<=D; i++) {
            // not use
            for(int j=0; j<i; j++) {
                int dist = i-j - (j == 0);
                int wake = t[dist % T];
                if(wake > ivs[i]) continue;
                chmin(dp[i][j], dp[i-1][j]);
            }

            // use
            chmin(dp[i][i], *min_element(dp[i-1], dp[i-1] + D + 1) + 1);
        }

        /*
        for(int i=0; i<=N; i++) {
            for(int j=0; j<=N; j++) {
                printf("dp[%d][%d] = ", i, j);
                if(dp[i][j] == INF) printf("INF\n");
                else printf("%d\n", dp[i][j]);
            }
        }
        */

        cout << *min_element(dp[D], dp[D] + D + 1) << endl;
    }
    return 0;
}

Measured memory_bytes: 3048
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int mod = 1e9+7;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(2000000);

int main() {
  int n;
  cin >> n;
  cout << mint(10).pow(n) - (mint)2 * mint(9).pow(n) + mint(8).pow(n) << endl;
  return 0; 
}


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

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;

    int counter = 0;
    for (int i = 1; i <= N; i++)
    {
        if (i < 10)
        {
            counter++;
        }
        else if (i >= 100 && i <= 999)
        {
            counter++;
        }
        else if (i >= 10000 && i <= 99999)
        {
            counter++;
        }
    }
    cout << counter << endl;
    return 0;
}


Measured memory_bytes: 256