akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>

using namespace std;

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

const ll mod = 1000000007;
ll fact[1500];
ll invfact[1500];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return pow(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}


ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}

ll dp[1010][1010];

int main(){
  int N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  make_fact(N+10);
  make_invfact(N+10);

  for(int i = 0; i < 1010; i++){
    for(int j = 0; j < 1010; j++){
      dp[i][j] = 0;
    }
  }
  dp[A-1][0] = 1;

  for(int j = A; j <= B; j++){
    for(int i = 0; i <= N; i++){
      ll c = 1LL;
      int n = N-i;
      ll x = dp[j-1][i];
      for(int k = 1; k <= min(i/j, D); k++){
        c = mul(c, comb(n+k*j, j));
        if(k < C) continue;

        x = add(x, mul(mul(c, dp[j-1][i-j*k]), invfact[k]));
      }
      dp[j][i] = x;
    }
  }

  cout << dp[B][N] << endl;

  return 0;
}


Measured memory_bytes: 8192
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
#define DD 1
#else
#define DD 0
#endif
#define Debug if(DD) printf("line %d\n",__LINE__)
#define deb(x) if(DD) cerr<<#x<<'='<<x<<endl
#define debug if(DD) printf
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void gg1(){write2(-1);exit(0);}
	void gg2(){puts("NO");exit(0);}
	
	const double eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int N=2e6+10;
	
	char str[N];
	ll C(int n,int m){if(n<m)return 0; ll ret=1;fo(i,n-m+1,n) ret=ret*i;fo(i,1,m) ret/=i;return ret; }
	void main()
	{
		scanf("%s",str+1);int n=strlen(str+1);int k=qread();ll ans=0;
		int cnt=0;
		fo(i,1,n)
		{
			fo(j,0,str[i]-'0'-1)
			{
				int c2=cnt+(j!=0);
				if(c2<=k) ans+=C(n-i,k-c2)*qpower(9,k-c2);
			}cnt+=(str[i]!='0');
		}
		cnt=0;fo(i,1,n) cnt+=(str[i]!='0');ans+=cnt==k;write(ans);
	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	#endif
	srand(time(0));
	mine::main();
	if(DD) cerr<<"Time: " <<1.0*clock()/CLOCKS_PER_SEC<<"s";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        
        //int x = stdIn.nextInt();
        int a[] = new int[n];
        //String s = stdIn.next();
        //String t = stdIn.next();
        //char c[] = s.toCharArray();
        //int sum = 0;
        //boolean flag = true;
        for(int i = 0; i < n; i++){
            a[i] = stdIn.nextInt();
        }
        
        
        int q = stdIn.nextInt();

        for(int i = 0; i < q; i++){
            int b = stdIn.nextInt();
            int e = stdIn.nextInt();
            int t = stdIn.nextInt();
            
            for(int k = 0; k < e - b; k++){
                int tmp = a[b + k];
                a[b + k] = a[t + k];
                a[t + k] = tmp;
                
            }
            
            
        }
        
        for(int i = 0; i < n - 1; i++){
            System.out.print(a[i] + " ");
        }
        System.out.println(a[n - 1]);

        //System.out.println();
        //System.out.print();

        stdIn.close();
    }
}





Measured memory_bytes: 36536
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  int A;
  int B;
  int C;
  cin >>A>>B>>C;
  if(C >=A-B) {
cout <<C-A+B << endl;
  }
  else {
cout <<0 << endl;
  }
}

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

int main()
{
int N;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;

	if( N >= 1000 )
		cout << "ABD" << endl;
	else
		cout << "ABC" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<cmath>
int main(){
	int A,B,C;
	scanf("%d%d%d",&A,&B,&C);
	if(A==5&&B==5&&C==7){
	   printf("YES\n");}
	else if(A==5&&B==7&&C==5){
		printf("YES\n");}
	else if(A==7&&B==5&&C==5){
		printf("YES\n");}
	else{
		printf("NO\n");}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	while(cin>>n>>m,n+m){
		vl a(n),b(m);
		cin>>a>>b;
		sort(all(b));

		vl c(1<<n,0);
		vvl dp(2,vl(1<<n,0));

		rep(i,m){
			int cur=i%2, nxt=1-i%2;
			fill(all(dp[nxt]),LINF);
			rep(s,1<<n){
				rep(j,n)if(!(s&(1<<j))){
					int ns=s|(1<<j);
					if(c[ns]==0) c[ns]=c[s]+a[j];
					chmin(dp[cur][ns],dp[cur][s]);
				}
				chmin(dp[nxt][s],dp[cur][s]+abs(b[i]-c[s]));
			}
		}
		puta(min(dp[m%2]));
	}
	return 0;
}


Measured memory_bytes: 4068
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str[2000];
	int i;
	
	fgets(str, 2000, stdin);
	
	for (i = 0; i < strlen(str); i++){
		
		if (str[i] == 'p' && str[i + 1] == 'e' && str[i + 2] == 'a' && str[i + 3] == 'c' && str[i + 4] == 'h'){
			str[i] = 'a';
			str[i + 1] = 'p';
			str[i + 2] = 'p';
			str[i + 3] = 'l';
			str[i + 4] = 'e';
		}
		else if (str[i] == 'a' && str[i + 1] == 'p' && str[i + 2] == 'p' && str[i + 3] == 'l' && str[i + 4] == 'e'){
			str[i] = 'p';
			str[i + 1] = 'e';
			str[i + 2] = 'a';
			str[i + 3] = 'c';
			str[i + 4] = 'h';
		}
	}
	
	printf("%s", str);
	
	return(0);
}

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

using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
#define int long long
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>void println(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
//lambda: [](int x, int y){return x<y;}

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

    return 0;
}


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

#define mp       make_pair
#define mt	  make_tuple
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF=1<<29;
const double EPS=1e-9;
const ll MOD = 1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
string str;
set<char> flag;
int main(){
  cin >> str;
  char tar;
  if (str[0] == 'B'){
    tar = 'W';
  }else{
    tar = 'B';
  }

  int opp = 0;
  int res = 0;
  for (int i = 0; i < str.size(); i++){
    //cout << opp << " " << tar << endl;
    if (str[i] == tar){
      if (opp > 0){
	res++;
	if (tar == 'W'){
	  tar = 'B';
	}else{
	  tar = 'W';
	}
	opp = i + 1;
      }
    }else{
      opp++;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
void solve() {
	double x1, x2, x3, x4, y1, y2, y3, y4;
	cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
	if ((x2 - x1) * (y4 - y3) == (y2 - y1) * (x4 - x3)) {
		if ((x2 - x1) * (y3 - y1) != (y2 - y1) * (x3 - x1))cout << "0\n";
		else {
			bool b = 0;
			if ((x1 - x3) * (x2 - x3) <= 0 && (y1 - y3) * (y2 - y3) <= 0)b = 1;
			if ((x1 - x4) * (x2 - x4) <= 0 && (y1 - y4) * (y2 - y4) <= 0)b = 1;
			if ((x3 - x1) * (x4 - x1) <= 0 && (y3 - y1) * (y4 - y1) <= 0)b = 1;
			if ((x3 - x2) * (x4 - x2) <= 0 && (y3 - y2) * (y4 - y2) <= 0)b = 1;
			cout << b << endl;
		}
	}
	else {
		double p = ((y2 - y1) * (x3 - x1) - (x2 - x1) * (y3 - y1)) / ((x2 - x1) * (y4 - y3) - (y2 - y1) * (x4 - x3));
		double x = x3 + p * (x4 - x3), y = y3 + p * (y4 - y3);
		cout << (((x1 - x) * (x2 - x) <= 0.000001 && (y1 - y) * (y2 - y) <= 0.000001) && (0 <= p && p <= 1)) << endl;
	}
}
signed main() {
	int n; cin >> n; for1(i, n)solve();
}


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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define drrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	os << "{";
	rep(i, (int)v.size()) {
		if (i)
			os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
	for (auto val : array)
		std::cout << val << ", ";
	std::cout << "\n";
}

const int MOD = 1'000'000'000 + 7;
const int INF = 1'000'000'000 + 5;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(16);

	int n; std::cin >> n;
	string s; std::cin >> s;
	rep(i, s.size()) {
		int tmp = s[i] - 'A';
		tmp += n, tmp %= 26;
		s[i] = 'A' + tmp;
	}
	std::cout << s << "\n";
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A, B;
  while(cin >> A >> B) {
    int c = 0, val = 1;
    while(val < B) {
      --val;
      val += A;
      ++c;
    }
    cout << c << '\n';
  }
  return 0;
}

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

double degree(int h, int m) {
	double s = m * 6;
	double l = h * 30 + m * 0.5;
	double d = abs(l - s);
	if (d > 180) d = 360 - d;
	return d;
}

string judge(int h, int m) {
	double d = degree(h, m);
	if (d < 30) return "alert";
	else if (d < 90) return "warning";
	return "safe";
}

int main() {
	int n; cin >> n;
	while (n--) {
		int h, m; char d;
		cin >> h >> d >> m;
		cout << judge(h, m) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <cstring>
#include <ctime>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
const int maxn = 105;

int d[maxn][maxn];
int n,m;
struct P{
  int x,y,z;
  P(){}
  P(int x,int y,int z):x(x),y(y),z(z){}
};
vector<P>e;

void pd(int&ret,int val){
  if(ret==-1||ret>val)ret = val;
}

int main() {
 //   freopen("in.cpp","r",stdin);
    cin>>n>>m;
    for(int i=1;i<=n;i++)
      for(int j=1;j<=n;j++)
        d[i][j] = (i==j)?0:-1;
    for(int i=1;i<=m;i++){
      int x,y,z;
      cin>>x>>y>>z;
      e.push_back(P(x,y,z));
      pd(d[x][y],z);
      pd(d[y][x],z);
    }
    for(int k=1;k<=n;k++)
      for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
          if(d[i][k]!=-1&&d[k][j]!=-1)
            pd(d[i][j],d[i][k]+d[k][j]);
    int ret=0;
    for(int i=0;i<m;i++)
      if(d[e[i].x][e[i].y]<e[i].z)ret++;
      cout<<ret<<endl;
    return 0;
}


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

int main() {

    int A, B;
    cin >> A >> B;
    if(A==B){
        cout << A*2;
        return 0;
    }
    cout << max(A, B)*2 - 1 << endl;
    return 0;
}

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

using namespace std;

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

  int n;
  cin >> n;

  int n_subsets = pow(2, n);

  for (int i = 0; i < n_subsets; i++) {
    bitset<18> bs(i);
    cout << i << ":";
    for (int j = 0; j < 18; j++) {
      if (bs.test(j)) {
        cout << " " << j;
      }
    }
    cout << endl;
  }
}




Measured memory_bytes: 3364
#include<cstdio>
#include<vector>
using namespace std;

int n, sum[1000001], isP[1000001];
vector<int> p;

int main() {
  for (int i = 2; i * i <= 1000000; i++) {
    bool ok = true;
    for (int j = 0; j < p.size(); j++) if (i % p[j] == 0) {
      ok = false;
      break;
    }
    if (ok) p.push_back(i);
  }
  for (int i = 2; i <= 1000000; i++) isP[i] = 1;
  for (int i = 0; i < p.size(); i++) {
    int k = 2;
    while (p[i] * k <= 1000000) isP[p[i] * k] = 0, k++;
  }
  for (int i = 1; i <= 1000000; i++) sum[i] = sum[i-1] + isP[i];
  while (scanf("%d", &n), n) {
    printf("%d\n", sum[n]);
    n = 0;
  }
}



Measured memory_bytes: 10512
data = input().split()
 
n = int(data[0])
m = int(data[1])
 
data = input().split()
 
homework = [int(s) for s in data]
day = 0
 
for i in homework:
  day += i

ans = n - day
if ans < 0:
  ans = -1

print(ans)

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

using namespace std;

int main(){

    string input;
    int tmp = 0;
    char op[3] = {'+','+','+'};

    cin >> input;
  
    for(int bit = 0; bit < (1<< 3); bit++){
        tmp = 0;
        for(int i = 0;i<3;i++){
            if(bit & (1 << i)){
                op[i] = '-';
                tmp += (input[i+1] - '0') * (-1);
            }else{
                op[i] = '+';
                tmp += (input[i+1] - '0');
            }
        }
        tmp += input[0] - '0';
        if(tmp == 7)break;
    }

    for(int i = 0; i<3;i++){
        cout << input[i] << op[i];
    }

    cout << input[3] << "=7" << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<long long int> vint;
typedef vector<vector<long long int>> vvint;
typedef vector<string> vstr;
typedef long long int llint;

llint gcd(llint x, llint y){
	while (y != 0){
		if (x > y){
			llint r = x%y;
			x = y;
			y = r;
		}
		else {
			llint r = y%x;
			y = r;
		}
	}
	return x;
}

int main(void) {
	llint N;
	cin>>N;
	llint ans = 0;
	vint a(N);
	map<llint, llint> mp;
	for (int i = 0; i < N; i++)cin >> a[i];
	
	vvint num(3, vector<long long int>(N));
	for (int i = 0; i < N; i++){
		for (int j = 0; j < 3; j++){
			if (j == 0)num[j][i] = a[i] - 1;
			if (j == 1)num[j][i] = a[i];
			if (j == 2)num[j][i] = a[i] + 1;
		}
	}
	for (int i = 0; i < N; i++){
		for (int j = 0; j < 3; j++){
			mp[num[j][i]]++;
			ans = max(ans, mp[num[j][i]]);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 9328
#include<iostream>
#include<vector>
#define pb push_back
using namespace std;
int A[100005];
vector<int> adj[100005];
int main(){
  int N,M;
  cin>>N>>M;
  for(int i=0; i<N; i++){
    cin>>A[i];
  }
  for(int i=0; i<M; i++){
    int n1,n2;
    cin>>n1>>n2;
    adj[n1].pb(A[n2-1]);
    adj[n2].pb(A[n1-1]);
  }
  int cnt=0;
  for(int i=1; i<=N; i++){
    if(adj[i].size()==0){cnt++; continue;}
    bool c=true;
    for(int j=0; j<adj[i].size(); j++){
      if(adj[i][j]>=A[i-1]){c=false; break;}
    }
    if(c) cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 9088
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

long long dp[2005][2005] = {};

int main() {
    
    long long n;
    cin >> n;
    vector<pair<long long, long long>> a(n + 1);
    for (long long i = 1; i < n + 1; ++i) cin >> a[i].first, a[i].second = i;
    sort(a.begin() + 1, a.end(), greater<pair<long long, long long>>());
    for (long long i = 1; i < n + 1; ++i) {
        for (long long j = 0; j < i; ++j) {
            long long L = j;
            long long R = i - 1 - j;
            dp[L + 1][R] = max(
                dp[L + 1][R],
                dp[L][R] + abs(L + 1 - a[i].second) * a[i].first
            );
            R = j;
            L = i - 1 - j;
            dp[L][R + 1] = max(
                dp[L][R + 1],
                dp[L][R] + abs(n - R - a[i].second) * a[i].first
            );
        }
    }
    long long ans = 0;
    for (long long i = 1; i < n + 1; ++i) {
        ans = max(ans, dp[i][n - i]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 26248
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr auto INF = INT_MAX / 2;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

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

	int k = 0;
	int st = 0;
	rep(i, s.size()) {
		if (s[i] == 'S')k++;
		if (s[i] == 'T' && k > 0) { k--;st++; }
	}

	cout << s.size() - 2 * st << endl;

}

Measured memory_bytes: 640
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
 
		Scanner sc  = new Scanner(System.in);

		int o= 0 ,p = 0,q = 0;
		long a = 0, b = 0, c = 0;
		char ch ;
		String str="";
		
        String s1 = sc.next();
        String s2 = sc.next();
        String s3 = sc.next();

        char[] c1 = s1.toCharArray();
        char[] c2 = s2.toCharArray();
        char[] c3 = s3.toCharArray();
        
        ch = c1[o];
        
        while(true){
            
            if(ch=='a'){
                if(o==s1.length()){
                    str = "A";
                    break;
                }
                 ch=c1[o];
                 o++;
            }else if(ch=='b'){
              if(p==s2.length()){
                    str = "B";
                    break;
                }
                 ch=c2[p];
                 p++;
            }else if(ch=='c'){
                 if(q==s3.length()){
                    str = "C";
                    break;
                }
                 ch=c3[q];
                 q++;
            }
        }
        
        System.out.print(str);
        System.out.println();
	}
}

Measured memory_bytes: 9680
#include<bits/stdc++.h>
using namespace std;
int n, a[200001], mau[200001], maa[200001];
int main () {
    ios_base :: sync_with_stdio (0);
    cin.tie (nullptr);
    cout.tie (nullptr);
    cin >> n;
    for (int i = 1; i <= n; ++ i) {
        cin >> a[i];
    }
    mau[0] = -1e9;
    maa[n + 1] = -1e9;
    for (int i = 1; i <= n; ++ i) {
        mau[i] = max (a[i], mau[i - 1]);
        maa[n - i + 1] = max (a[n - i + 1], maa[n - i + 2]);
    }
    for (int i = 1; i <= n; ++ i) {
        cout << max (mau[i - 1], maa[i + 1]) << "\n";
    }
}


Measured memory_bytes: 3968
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double[] p = new double[1001];
		p[0] = 0;
		for(int i = 1; i < 1001; i++) {
			double h = 0;
			for(int j = 1; j < i + 1; j++) {
				h += (double) j / (double) i;
			}
			p[i] = h;
		}
		int n = sc.nextInt();
		int k = sc.nextInt();
		double[] sum = new double[n + 1];
		sum[0] = 0;
		for(int i = 1; i < n + 1; i++) {
			sum[i] = sum[i - 1] + p[sc.nextInt()];
		}
		double ans = 0;
		for(int i = k; i < n + 1; i++) {
			ans = Math.max(ans, sum[i] - sum[i - k]);
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 72380
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int x = 0;
    int y = 0;
    int yes = 0;
    for(x=0;x<N;x++){
        for(y=0;y<N;y++){
        if((x*4)+(y*7)==N){
            yes = 1;
            break;
            }
        }
    }
    if(yes == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
        return 0;
}


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


int main() {

    int N, M, Q;
    int a, b, c, d;

    cin >> N >> M >> Q;
    vector<vector<int>> t(60);
    for (int i = 0; i < Q; i++) {
        cin >> a >> b >> c >> d;
        t[i].push_back(a);
        t[i].push_back(b);
        t[i].push_back(c);
        t[i].push_back(d);
    }

    // vector<vector<int>> next (11);
    // for (int i = 1; i <= 10; ++i) {
    //     for (int j = i; j <= 10; ++j) {
    //         next[i].append(j);
    //     }
    // }

    vector<int> A(15, 1), B(15, 0);
    A[N] = M;
    // B = A;
    int ans = 0;
    int sum;
    int p = 0;
    while(true) {
        if (A != B) {
            // for (int i = 0; i < N; ++i) {
            //     cout << A[i] << " ";
            // }
            // cout << endl;
            sum = 0;
            for (int q = 0; q < Q; ++q) {
                a = t[q][0];
                b = t[q][1];
                c = t[q][2];
                d = t[q][3];
                if (A[b-1] - A[a-1] == c) {
                    sum += d;
                }
            }
            ans = max(ans, sum);

        }
        B = A;

        if (p == 0 && A[0] == M) {
            break;
        }

        if (A[p+1] < M) {
            p++;
        }
        else {
            if (A[p] < M) {
                A[p]++;
            }
            else {
                p--;
                A[p]++;
                for (int j = p+1; j < N; ++j) {
                    A[j] = A[p];
                }

            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

int main(){
    int A,B,C;
    cin>>A>>B>>C;
    int K;
    cin>>K;

    vector<int> M{A,B,C};
    sort(M.begin(),M.end());

    for(int i=0;i<K;i++) M[2] *= 2;

    cout<<M[0]+M[1]+M[2]<<endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001

int main(void) {
	int n; cin >> n;
	vi w(n); rep(i,n) cin >> w[i];
	int sum = 0;
	rep(i,n) sum += w[i];
	double half = sum/2.;
	int s1 = 0;
	rep(i,n){
		if(s1+w[i]>half){
			if(abs(s1-half)<abs(s1+w[i]-half)) break;
			else{
				s1+=w[i]; break;
			}
		}
		else s1 += w[i];
	}
	int s2 = sum - s1;
	cout << abs(s1-s2) << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;

#define rep(i,x) for(Int i = 0; i < (Int)(x); i++)
#define rrep(i,x) for(Int i = ((Int)(x) - 1); i >= 0; i--)
#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back


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

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

Int dx[4] = {1,0,-1,0};
Int dy[4] = {0,1,0,-1};
const Int INF = 1001002003004005006ll;
const Int mod = 1e9 + 7;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//


int n;

int s[110];

int memo[110][10010];

int dfs(int i, int sum){
        if(i == n){
                if(sum%10 != 0){
                        return sum;
                }
                else{
                        return 0;
                }
        }

        if(memo[i][sum] != -1) return memo[i][sum];

        int ret = 0;

        int a = dfs(i + 1, sum + s[i]);
        int b = dfs(i + 1, sum);

        ret = max(a,b);

        return memo[i][sum] = ret;
}


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

        memset(memo,-1,sizeof(memo));

        int ans = dfs(0,0);

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








Measured memory_bytes: 4608
a = []
for i in range(6):
  po = int(input())
  a.append(po)
           
flag = 0
count = 0
for i in range(5):
  for j in range(4-i):
    sa = abs(a[i]-a[i+j+1])
    count = count + 1
    if sa > a[5]:
      flag = 1
      break

if flag == 0:
  print("Yay!")
else:
  print(":(")
      


Measured memory_bytes: 2940
import sys

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

enough=[]
lack=[]
for i in range(n):
    if a[i]-b[i]<0:
        lack.append(a[i]-b[i])
    else:
        enough.append(a[i]-b[i])

change=(-1)*sum(lack)
enough.sort()
enough=enough[::-1]

i=0
while change>0:
    if i>=len(enough):
        print(-1)
        sys.exit()
    change-=enough[i]
    i+=1

print(i+len(lack))


Measured memory_bytes: 18708
#include <cstdio>
#include <algorithm>    
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#define pb push_back
#define mk make_pair
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned int uii;
typedef pair<int,int> pii;
typedef pair<LL, LL> pll;
typedef pair<int, pair<int, int> >piii;
typedef unsigned long long uLL; 
typedef vector<int> vii; 
const int inf = 1e9;
const LL INF = 1e18;
const int M = 1e9 + 7;
//__int128
const int maxn = 1e5 + 5;
LL d[maxn];
bool vis[maxn];

int main(int argc, char const *argv[])
{
#ifndef ONLINE_JUDGE
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
#endif
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; ++i){
		int x;
		cin >> x;
		vis[x] = 1;
	}
	d[0] = 1;
	if(!vis[1]) d[1] = 1;
	for(int i = 2; i <= n; ++i){
		if(!vis[i])
			d[i] = (d[i - 1] + d[i - 2]) % M;
	}
	cout << d[n] << endl;
	return 0;
}

Measured memory_bytes: 1152
# -*- coding: utf-8 -*-
import sys
import os

x,y,z = [input() for i in range(3)]
x = int(x)
z = int(z)

moji = y[z-1]

y = list(y)

for i in range(x):
    if y[i] != moji:
        y[i] = '*'

print("".join(y))

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

using namespace std;
int a[500000],b[500000],n;
long long sums,ans;

int main()
{
    scanf("%d",&n);
    long long sums = 0;int tmp;
    for(int i=0;i<n;++i){
        scanf("%d",&tmp);++a[tmp-1];
    }

    vector<int> vn;
    sort(a,a+n);reverse(a,a+n);
    int j = n-1;
    int rs = 0;
    for(int i=1;i<=n;++i){
        while(j>=0&&a[j]<i){
            rs += a[j--];
        }
        b[i] = rs/i + (j+1);
    }

    j = n;
    for(int i=1;i<=n;++i){
        while(j>=1&&b[j]<i) --j;
        printf("%d\n",j);
    }
    return 0;
}


Measured memory_bytes: 6120
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

// -------------------</optimizations>--------------------
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define d long double
#define pii pair<int,int>
#define pb push_back
#define pf push_front
#define cases int tc;cin>>tc;while(tc--)
#define N 100003
#define M 103
#define inf LLONG_MAX
#define hahaha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//int mod=1e9+7;
//int mod=998244353;
int dp[M][N];

signed main()
{
    hahaha
    
    memset(dp,0,sizeof dp);
    int n,W;
    cin>>n>>W;
    int w[n+1],v[n+1],i,j;
    for(i=1;i<=n;++i)
        cin>>w[i]>>v[i];
    
    for(i=1;i<=n;++i)
    {
        for(j=1;j<=W;++j)
        {
            if(j>=w[i])
                dp[i][j]=max(dp[i][j],dp[i-1][j-w[i]]+v[i]);
            dp[i][j]=max(dp[i][j],dp[i-1][j]);
        }
    }
    
    cout<<dp[n][W];
        
    return 0;
}


Measured memory_bytes: 80768
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>

using namespace std;
typedef pair<int, int> P;
static const int INF = 99999999;
struct SEdge
{
	int To;
	int Cost;
};
vector<int> d;
vector< vector<SEdge> > G;

void Dijkstra(int s)
{
	fill(d.begin(), d.end(), INF);
	d[s] = 0;
	priority_queue<P, vector<P>, greater<P> > PQue;
	PQue.push(P(0, s));
	while(!PQue.empty())
	{
		P p = PQue.top();
		PQue.pop();
		int v = p.second;
		if(d[v] < p.first)
		{
			continue;
		}
		for(int i = 0; i < G[v].size(); ++i)
		{
			SEdge e = G[v][i];
			if(d[e.To] > d[v] + e.Cost)
			{
				d[e.To] = d[v] + e.Cost;
				PQue.push(P(d[e.To], e.To));
			}
		}
	}
}

void solve()
{
	int V, m;
	while(cin >> V >> m, V || m)
	{
		d.clear();
		for(int i = 0; i < G.size(); ++i)
		{
			G[i].clear();
		}
		G.clear();
		d.resize(V);
		G.resize(V);
		for(int i = 0; i < m; ++i)
		{
			int a;
			cin >> a;
			if(a == 0)
			{
				int b, c;
				cin >> b >> c;
				--b;
				--c;
				Dijkstra(b);
				if(d[c] == INF)
				{
					cout << -1 << endl;
				}
				else
				{
					cout << d[c] << endl;
				}
			}
			else if(a == 1)
			{
				int b, c, d;
				cin >> b >> c >> d;
				--b;
				--c;
				SEdge e1, e2;
				e1.To = c;
				e2.To = b;
				e1.Cost = e2.Cost = d;
				G[b].push_back(e1);
				G[c].push_back(e2);
			}
		}
	}
}

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

Measured memory_bytes: 944
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    string s;
    cin>>s;
    if(s=="SUN"){
        cout<<7<<endl;
    }
    if(s=="MON"){
        cout<<6<<endl;
    }
    if(s=="TUE"){
        cout<<5<<endl;
    }
    if(s=="WED"){
        cout<<4<<endl;
    }
    if(s=="THU"){
        cout<<3<<endl;
    }
    if(s=="FRI"){
        cout<<2<<endl;
    }
    if(s=="SAT"){
        cout<<1<<endl;
    }
}

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

ll ppow(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1)res=(res*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return res;
}
ll sum[500][500];
ll a[500],b[500];
ll dp[500][500];

int main(){
	int n,c;scanf("%d%d",&n,&c);
	rep(i,500){
		for(int j=1;j<500;j++){
			(sum[i][j]+=sum[i][j-1])%=MOD;
			(sum[i][j]+=ppow(j,i))%=MOD;
		}
	}
	rep(i,n)scanf("%lld",&a[i]),a[i]--;
	rep(i,n)scanf("%lld",&b[i]);
	dp[0][0]=1;
	rep(i,n)rep(j,c+1){
		for(int k=0;j+k<=c;k++){
			(dp[i+1][j+k]+=dp[i][j]*(sum[k][b[i]]+MOD-sum[k][a[i]])%MOD)%=MOD;
		}
	}
	cout<<dp[n][c]<<endl;
}

Measured memory_bytes: 3712
/*2019/07/29 */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
typedef long long int ll;
void llswap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int desc(const void *a,const void *b){return *(int*)b-*(int*)a;}
/*
int asc_t(const void *a,const void *b){return ((user_t*)a)->score - ((user_t*)b)->score;}
int desc_t(const void *a,const void *b){return ((user_t*)b)->score - ((user_t*)a)->score;}
*/

int main(){
    char s[1000],t[1000];
    char str[10000];
    int s_len;

    scanf("%s",s);
    scanf("%s",t);

    s_len=strlen(s);

    strcat(str,t);
    strcat(str,t);

    for(int i=0;s[i]!='\0';i++){
        if(!strncmp(s,&str[i],s_len)){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
import math


inputa = input().split()
inputb = input().split()

a = int(inputa[0])
# b = int(inputa[1])
# c = int(inputa[2])

# x = int(inputb[0])
# y = int(inputb[1])

# inputList=[]
# for i in range(a):
#     inputNum = input()
#     inputList.append(inputNum)

listb = []
listb = [int(n) for n in inputb]

sum = 0
for i in range(a):
    sum += listb[i]

s1 = 0
min = -1
for i in range(a):
    s1 += listb[i]
    tmps2 = sum -s1
    
    tmpabs = abs(s1 - tmps2)
    if min == -1:
        min = tmpabs
    elif min > tmpabs:
        min = tmpabs
        

print(int(min))


Measured memory_bytes: 38256
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=1e5+5;
const int mod=1e9+7;
int n,fg,sum[N],nxt[N][3],f[N],ans;
char str[N];
void Inc(int &x,int y){
	x+=y;x>=mod?x-=mod:x;
}
int main(){
	scanf("%s",str+1);n=strlen(str+1);
	for(int i=1;i<n;++i)fg|=(str[i]==str[i+1]);
	if(!fg)return puts("1"),0;
	for(int i=1;i<=n;++i)sum[i]=(sum[i-1]+(str[i]=='a'?1:2))%3;
	for(int i=n-1;~i;--i){
		for(int j=0;j<3;++j)nxt[i][j]=nxt[i+1][j];
		nxt[i][sum[i+1]]=i+1;
	}
	f[0]=1;
	for(int i=0;i<n;++i)
		for(int j=1;j<3;++j)
			if(nxt[i][(sum[i]+j)%3])
				Inc(f[nxt[i][(sum[i]+j)%3]],f[i]);
	for(int i=1;i<=n;++i)
		if(sum[i]==sum[n])
			Inc(ans,f[i]);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 2176
import heapq

j=0
a=list()
c=list()
for j in range(10):
    b=input()
    a.append(b)
a=[int(s) for s in a]
a.sort(reverse=True)

for j in range(11,21):
    d=input()
    c.append(d)
c=[int(s) for s in c]
c.sort(reverse=True)

print(sum(heapq.nlargest(3,a)),sum(heapq.nlargest(3,c)))


Measured memory_bytes: 5664
import java.util.*;
import java.io.*;
public class Main
{
    static final long mod=(long)1e9+7;
    public static void main(String argd[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        int s=Integer.parseInt(br.readLine());
        long arr[]=new long[2001];
        Arrays.fill(arr,1);
        arr[1]=arr[2]=0;
        arr[0]=1;
        for(int i=1;i<=2000;i++)
        {
            boolean done[]=new boolean[2001];
            for(int j=3;j<=(i+1)/2;j++)
            {
                if(j>=3)
                {
                    if(i-j==j&&!done[j])
                    {
                        arr[i]=(arr[j]+arr[i])%mod;
                        done[j]=true;
                    }
                    else if(i-j>=3&&!done[j]&&!done[i-j])// if(i-j>=3&&!done[j]&&!done[i-j])
                    {
                        arr[i]+=arr[j]+arr[i-j];
                        arr[i]%=mod;
                        done[j]=done[i-j]=true;
                    }
                }
            }
        }
        pw.println(arr[s]);
        pw.flush();
        pw.close();
    }
}

Measured memory_bytes: 37568
#include <bits/stdc++.h>
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define debug(var) std::cout << #var << " : " << var << std::endl;
using ll = long long;
using ull = unsigned long long;
ll mod = 1e9 + 7;


int main(){


    int A, B; std::cin >> A >> B;

    if((A + B) % 2 == 0)std::cout << (A + B) / 2;
    else std::cout << "IMPOSSIBLE";


    return 0;
}

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

using namespace std;

bool isPalindrome(string x)
{
    string palidromo = x;
    reverse(palidromo.begin(), palidromo.end());
    return x == palidromo;
}

int main ()
{
    string s = "", first = "", last = "";
    cin >> s;
    int n = s.size();
    for (int i = 0; i < (n-1)/2; i++)
        first += s[i];
    for (int i = (n+3)/2-1; i < n; i++)
        last += s[i];

    cout << (isPalindrome(s) && isPalindrome(first) && isPalindrome(last) ? "Yes" : "No" ) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

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

	vector<int> H(N,0);
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}

	vector<bool> good(N,true);
	for (int i = 0; i < M; i++) {
		int a,b; cin >> a >> b;
		a--;b--;
		if (H[a] > H[b]) {
			good[b] = false;	
		}else if (H[a] < H[b]) {
			good[a] = false;	
		}else {
			good[a] = false;	
			good[b] = false;	
		}
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (good[i]) {
			ans++;
		}
	}

	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 3784
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for(int i = x; i < n; i++)

int main(void){
    // Your code here!
    int H,N;
    cin >> H >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    int sum = 0;
    rep(i, N) sum += A[i];
    if (H - sum <= 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 640
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){
	ll n,i;cin>>n;vi v(n),d(n+1,0);for(i=0;i<n;i++) cin>>v[i];
	d[0]=1;for(i=0;i<n;i++) if(d[v[i]-1]) d[v[i]]=1;
	for(i=1;i<=n;i++) if(!d[i]) break;
	if(i==1) cout<<"-1\n"; else cout<<n-i+1<<endl;
}


Measured memory_bytes: 3328
import numpy as np

N=int(input())
ab=np.array([list(map(int, input().split())) for i in range(N)])

ab=ab[np.argsort(ab[:, 1])]

output='Yes'
t=0
for i in range(N):
  t+=ab[i, 0]
  if t>ab[i, 1]:
    output='No'
    
print(output)

Measured memory_bytes: 62480
#include <bits/stdc++.h>
using namespace std;
const int maxn = 5222, mod = 1'000'000'007;
int mul(long long a, long long b){
	return a * b % mod;
}
int xp(int a, int b){
	int r = 1;
	for(; b ; b >>= 1, a = mul(a, a)) if(b&1) r = mul(r, a);
	return r;
}
int fat[maxn], ifat[maxn];
void init(){
	fat[0] = 1;
	for(int i = 1; i < maxn; i++) fat[i] = mul(i, fat[i - 1]);
	for(int i = 0; i < maxn; i++) ifat[i] = xp(fat[i], mod - 2);
	for(int i = 0; i < maxn; i++) assert(mul(fat[i], ifat[i]) == 1);
}
int ncr(int n, int r){
	if(n < r) return 0;
	if(r < 0 || n < 0) return 0;
	return mul(fat[n], mul(ifat[r], ifat[n - r]));
}
int distr(int n, int r){
	return ncr(n + r - 1, r);
}
int main(){
	init();
	int n, k; cin >> n >> k;
	int red = k, blue = n - k;
	for(int i = 1; i <= k; i++){
		cout << mul(distr(i, red - i), distr(i + 1, blue - (i - 1))) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int h,w,k;
    cin>>h>>w>>k;
    vector<vector<char>> c(h,vector<char>(w));
    for(int i=0; i<h; i++) for(int j=0; j<w; j++) cin>>c[i][j];
    int ans=0;
    for(int i=0; i<(1<<h); i++){
        for(int j=0; j<(1<<w); j++){
            int cnt=0;
            for(int k=0; k<h; k++){
                for(int l=0; l<w; l++){
                    if(!(i&(1<<k))&&!(j&(1<<l))&&c[k][l]=='#'){
                        cnt++;
                    }
                }
            }
            if(cnt==k) ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1e9+7
#define hell2 1e9+9
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll long long
#define ld long double 
#define no_of_digits(n) floor(log10(n)) + 1
#define see(x) cout << (#x) << " is " << (x) << endl
#define INF 1e9

using namespace std;

ll mult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll multbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=multbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;
}
ll add(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll sub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
int isPowerof2(ll x) { return (x && !(x & x-1)); } 
ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; } 

// max({a, b, c, d})

vector<ll>adj[200005];
ll update[200005];
ll ans[200005];

int binaryToDecimal(string n) 
{ 
    string num = n; 
    int dec_value = 0; 
  
    // Initializing base value to 1, i.e 2^0 
    int base = 1; 
  
    int len = num.length(); 
    for (int i = len - 1; i >= 0; i--) { 
        if (num[i] == '1') 
            dec_value += base; 
        base = base * 2; 
    } 
  
    return dec_value; 
} 

bool isPerfectSquare(long double x) 
{   
  // Find floating point value of  
  // square root of x. 
  long double sr = sqrt(x); 
  
  // If square root is an integer 
  return ((sr - floor(sr)) == 0); 
} 

int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll low = ceil(((ld)a/c))*c;
    ll lowd = ceil(((ld)a/d))*d;
    // cout << low << "\n";

    ll high = (b/c)*c;
    ll highd = (b/d)*d;

    ll multc = (high-low)/c+1;
    ll multd = (highd-lowd)/d+1;

    ll prod = c*d/__gcd(c, d);

    ll lowf = ceil(((ld)a/prod))*prod;
    ll highf = (b/prod)*prod;

    ll multf = (highf-lowf)/prod+1;

    // see(multc);
    // see(multd);
    // see(multf);

    cout << (b-a+1)-(multc + multd - multf) << "\n";
}




Measured memory_bytes: 6016