akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
using namespace std;

void Main() {
    // input
    int N, Y;
    cin >> N >> Y;
    Y /= 1000;


    // translate
    for (int x = 0; x <= N; x++) {
        for (int z = 0; z <= N; z++) {
            int y = N - x - z;
            if (y < 0) {
                continue;
            }
            if (10 * x + 5 * y + z == Y) {
                cout << x << " " << y << " " << z << endl;
                return;
            }
        }
    }

    cout << "-1 -1 -1" << endl; 


    // output

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,y,i,j,k,sum,l=0;
  scanf("%d %d\n",&n,&y);
  for(i=0;i<=n;i++){
    for(j=0;j<=n;j++){
      k=n-i-j;
      if(k>=0){
        sum=10000*i+5000*j+1000*k;
        if(y==sum){
          printf("%d %d %d\n",i,j,k);
          l=1;
          break;
        }
      }
      if(l==1){
        break;
      }
    }
    if(l==1){
      break;
    }
  }
  if(l==0){
    printf("-1 -1 -1\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define ll long long
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define moder 1000000007
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int n,k,h[100010];
int dp[100010];
signed main(){
	cin>>n>>k;
	rep(i,n)cin>>h[i];
	fill(dp,dp+n,INF);
	dp[0]=0;
	for(int i=1;i<n;i++){
		for(int j=i-1;j>=0&&j>i-1-k;j--){
			dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
		}
	}
	cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;
using namespace std;

int main() {
    int n,a,b;
    cin >> n;
    a = 800*n;
    b = (n/15)*200;
    cout << a-b << endl;

    return 0;
}

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

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N, X;
int A[100111];

int main() {
    scanf("%d%d", &N, &X);
    REP (i, N) scanf("%d", A+i);
    LL ans = 0;
    REP (i, N-1) {
	if (A[i] + A[i+1] > X) {
	    int d = A[i] + A[i+1] - X;
	    ans += d;
	    int g = min(d, A[i+1]);
	    d -= g;
	    A[i+1] -= g;
	}
    }
    printf("%lld\n", ans);


    return 0;
}



Measured memory_bytes: 768
#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)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

const int MAX_N=100001;
const int mod=1000000007;
ll fact[MAX_N+1];
ll inv[MAX_N+1],finv[MAX_N+1];
int inv_init(ll n,ll p){
    inv[1]=1;
    FOR(i,2,n+1) inv[i]=p-(p/i)*inv[p%i]%p;
    fact[0]=finv[0]=1;
    FOR(i,1,n+1){
        fact[i]=fact[i-1]*i%p;
        finv[i]=finv[i-1]*inv[i]%p;
    }
    return 0;
}
ll comb_mod(ll n,ll k,ll p){
    if(k<0||n<k) return 0;
    return finv[k]*finv[n-k]%p*fact[n]%p;
}
int n,k;
ll a[100001];
int main(){
    cin>>n>>k;
    rep(i,n) cin>>a[i];
    sort(a,a+n);
    inv_init(n+1,mod);
    ll r=0,l=0;
    rep(i,n){
        r+=comb_mod(i,k-1,mod)*a[i];
        l+=comb_mod(n-i-1,k-1,mod)*a[i];
        r%=mod,l%=mod;
    }
    cout<<(r+mod-l)%mod<<endl;
    return 0;
}

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

using namespace std;

#define ll long long int
#define MOD 1000000007

int K;
vector<vector<int>> to;

ll calc(int current, int parent)
{
    if (parent < 0)
    {
        ll ret = K;

        for (int i = 0; i < to[current].size(); i++)
        {
            ret = (ret * (K - i - 1)) % MOD;
        }
        for (int i : to[current])
        {
            ret = (ret * calc(i, current)) % MOD;
        }
        return ret;
    }
    else
    {
        ll ret = 1;

        for (int i = 0; i < to[current].size() - 1; i++)
        {
            ret = (ret * (K - i - 2)) % MOD;
        }
        for (int i : to[current])
        {
            if (i != parent)
            {
                ret = (ret * calc(i, current)) % MOD;
            }
        }
        return ret;
    }
}
int main()
{
    int N;

    cin >> N >> K;

    to = vector<vector<int>>(N + 1, vector<int>());

    for (int i = 0; i < N - 1; i++)
    {
        int a, b;

        cin >> a >> b;

        to[a].push_back(b);
        to[b].push_back(a);
    }
    cout << calc(1, -1) << endl;

    return 0;
}

Measured memory_bytes: 13112
//Compiler optimization
#pragma GCC optimize("Ofast")

//include
#include <bits/stdc++.h>
using namespace std;

//typedef
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<vl> mat;

//macro
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define each(x, v) for (auto &x : v)

//abbreviation
#define pb push_back
#define elif else if
#define mp make_pair
#define endl '\n'

//debug
#define debug(x) cerr << #x << ": " << x << endl

//const
const  ll INF = 1e18;

char c[10][10];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll h,w,k;cin >> h >> w >> k;
    fr(i,h)fr(j,w)cin >>c[i][j];
    ll res = 0;
    fr(maskr, 1<<h){
        fr(maskc, 1<<w){
            ll black = 0;
            fr(i,h)fr(j,w){
                if(((maskr >> i)&1)==0 && ((maskc >>j)&1) == 0 && (c[i][j] == '#'))black++;
            }
            if(black == k)res++;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3608
# include<cstdio>
# include<algorithm>
# include<cmath>
using namespace std;
const int MAX=1e3+4;
int n;
double a[MAX];
int main() {
	double s;
	scanf("%d",&n);
	for(int i=1; i<=n; ++i)
		scanf("%lf",&a[i]),s+=a[i];
	s=s/n;
	double minn=1e18,k=0;
	for(int i=1; i<=n; ++i)
		if(abs(a[i]-s)<minn) k=i-1,minn=abs(a[i]-s);
	printf("%d",int(k));
	}


Measured memory_bytes: 128
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define CLR(x) memset(x,0,sizeof x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 1000000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f
typedef long long ll;
//orz yht
using namespace std;
string i_s(int x){
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}
int n,ans=1,sol=1;
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++){
		ans*=3;
		int x;
		cin>>x;
		if(x%2==0)
		sol*=2;
	}
	cout<<ans-sol;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 int main(void){
   int i,x,a,b,c,d,e,f;
   scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
    i=a*1+b*5+c*10+d*50+e*100+f*500;
    x=i/1000;
    if(i<1000){
        printf("0\n");
    }
    if(i>=1000){
        printf("1\n",x);
    }

    return 0;
 }

Measured memory_bytes: 584
#include <iostream>
#include <map>
#include <algorithm>
#define N 210
using namespace std;

int n,m;
int d[N][N];

bool check(){ /* 誤った規則があればfalse */
  for( int k=0;k<m;k++ )
    for( int i=0;i<m;i++ )
      for( int j=0;j<m;j++ )
	d[i][j] = min( d[i][j],d[i][k]+d[k][j] );

  for( int i=0;i<m;i++ )
    if( d[i][i]<0 )
      return false;
  return true;
}

int main(){
  string a,b, s;
  int x;
  char c;

  while( cin>>n && n ){
    m=n*2;
    for( int i=0;i<N;i++ ){
      for( int j=0;j<N;j++ )
	d[i][j] = 100000000;
      d[i][i] = 0;
    }
    map<string,int> units; // units[ a ] でaの配列番号が分かる
    m=0;
    for( int i=0;i<n;i++ ){
      cin >> x >> a >> c; // 1 [A] =
      cin >> x >> c;  // 10^
      cin >> x >> b;  // [x] [B];

      if( units.find( a )==units.end() )
	units[a] = m++;
      if( units.find( b )==units.end() )
	units[b] = m++;

      int an=units[a], bn=units[b];
      
      d[an][bn] = -x;
      d[bn][an] =  x;
    }

    if( check() ) cout << "Yes" << endl;
    else          cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1120
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, m;
	cin >> n >> m;
	if (n == m) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int col[2];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    int n = s.size();
    int ans = 0;
    for(int i=1;i<n;i++){
        if(s[i-1]!=s[i]) ans++;
    }
    cout<<ans<<endl;


}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
    string s;
    cin >> s;
    ll si = s.size();
    ll res = 0;
    for(int i = 0;i < si;i++){
        res += s[i] - '0';
        res %= 9;
    }
    if(res == 0)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3720
#include "bits/stdc++.h"

using namespace std;

void Main() {
    int N, M, K;
    cin >> N >> M >> K;
    map<int, set<int>> friends;
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        if (friends.count(a) == 0) {
            friends.insert(make_pair(a, set<int>()));
        }
        friends[a].insert(b);
        if (friends.count(b) == 0) {
            friends.insert(make_pair(b, set<int>()));
        }
        friends[b].insert(a);
    }
    map<int, set<int>> blocks;
    for (int i = 0; i < K; ++i) {
        int a, b;
        cin >> a >> b;
        if (blocks.count(a) == 0) {
            blocks.insert(make_pair(a, set<int>()));
        }
        blocks[a].insert(b);
        if (blocks.count(b) == 0) {
            blocks.insert(make_pair(b, set<int>()));
        }
        blocks[b].insert(a);
    }

    vector<int> numCandidates(N + 1, -1);
    for (int i = 1; i <= N; ++i) {
        if (numCandidates[i] >= 0) {
            continue;
        }
        queue<int> q;
        set<int> candidates;
        q.push(i);
        candidates.insert(i);
        while (!q.empty()) {
            auto p = q.front();
            q.pop();
            if (friends.count(p) == 0) {
                continue;
            }
            for (auto e : friends[p]) {
                if (candidates.count(e) == 0) {
                    q.push(e);
                    candidates.insert(e);
                }
            }
        }

        for (auto e : candidates) {
            int n = candidates.size() - 1;
            if (friends.count(e) > 0) {
                n -= friends[e].size();
            }
            for (auto b : blocks[e]) {
                if (candidates.count(b) > 0) {
                    --n;
                }
            }
            numCandidates[e] = n;
        }

    }

    for (int i = 1; i <= N; ++i) {
        if (i > 1) {
            cout << " ";
        }
        cout << numCandidates[i];
    }
    cout << endl;

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 45720
#include<stdio.h>

int main(){
  int i;
  int N,count;
  scanf("%d",&N);

  char str[N+1];
  scanf("%s",str);

  count=0;
  for(i=0; str[i]!='\0'; i++){
    if((str[i]=='O' && str[i+1]=='X') || (str[i]=='X' && str[i+1]=='O')){
      count++;
      i++;
    }
  }
  printf("%d\n",count);
  return 0;
}
    



Measured memory_bytes: 2148
s=input()
t=input()

def change(s):
    u=str()
    for i in range(len(s)):
        if i==0:
            u+=s[len(s)-1]
        else:
         u+=s[i-1]
    return u

flag=False

if(s==t): 
    flag=True

for i in range(len(s)-1):
    s=change(s)
    #print(s)
    if(s==t):
        flag=True
        break

if(flag==False):
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <list>
#include <iomanip>
#include <queue>
#include <cmath>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
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; }
const long long mod = 1e9 + 7;
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
ll dx[] = { 1, 0 , -1,  0 }, dy[] = { 0, 1, 0, -1 };
ll cb(ll a, ll b);

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

	ll x, y, cnt = 0;
	string ans = "No";
	rep(i, n) {
		cin >> x >> y;
		if (x == y) cnt++;
		else cnt = 0;
		if (cnt >= 3) ans = "Yes";
	}

	cout << ans;
}


ll cb(ll a, ll b) {
	ll ans = 1;
	rep(i, b) ans *= (a - i);
	rep(i, b) ans /= (b - i);

	return ans;
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<lli,lli>
#define vi              vector<lli>
#define mii             map<lli,lli>
#define pqb             priority_queue<lli>
#define pqs             priority_queue<lli,vi,greater<lli> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            lli x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int n;
int add(lli a, lli b) {
	return ((a % mod) + (b % mod)) % mod;
}
int mul(lli a, lli b) {
	return ((a % mod) * (b % mod)) % mod;
}
struct M {
	vector < vector <int> > t;
	M() {
		t.resize(n, vector <int>(n));
	}
	M operator* (const M& a) const {
		M c = M();
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++ ) {
				for (int k = 0; k < n; k++) {
					c.t[i][k] = add(c.t[i][k], mul(this->t[i][j], a.t[j][k]));
				}
			}
		}
		return c;
	}

};
void solve() {
	cin >> n;
	lli k;
	cin >> k;
	vector < vector <int> > arr(n, vector <int>(n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> arr[i][j];
		}
	}
	M a = M();
	M b = M();
	b.t = arr;
	for (int i = 0; i < n; i++) {
		a.t[i][i] = 1;
	}
	while (k > 0) {
		if (k & 1) {
			a = a * b;
		}
		b = b * b;
		k >>= 1;
	}
	int ret = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			ret = add(ret, a.t[i][j]);
		}
	}
	cout << ret << endl;
}
void ss()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}

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

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

using namespace std;

#define long long long
#define INF ((long) 2e18)
#define MOD ((long) (1e9 + 7))
#define umap unordered_map

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

    long t = 1;
    //cin >> t;

    while (t--) {
        long n;
        cin >> n;

        string s;
        cin >> s;

        long ans = 0;
        long l = 0;
        for (long r = n-1; r > l; r--) {
            if (s[r] == 'R') {
                while (s[l] == 'R' and l < r) l++;
                if (r == l) break;
                swap(s[l], s[r]);
                ans++;
            }
        }
        printf("%lld\n", ans);
    }
}


Measured memory_bytes: 3832
#include <stdio.h>

int main()
{
    int n, k, i;
    int a[200000];
    long sum1 = 0, sum2 = 0;

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

    for (i = 0; i < k; i++) {
        sum1 += a[i];
    }
    sum2 = sum1 - a[0] + a[k];

    for (i = k; i < n; i++) {
        if (sum1 < sum2)
            printf("Yes\n");
        else 
            printf("No\n");
        
        sum1 = sum2;
        sum2 = sum2 - a[i-k+1] + a[i+1];
    }

    return 0;
}

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

using namespace std;

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    vector<int> diff(n+5,0);
    for(int i=0;i<m;i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        diff[a]++;
        diff[b+1]--;
    }
    int now=0;
    int res=0;
    for(int i=1;i<=n;i++)
    {
        now+=diff[i];
        if(now==m) res++;
    }
    printf("%d\n",res);
    return 0;
}


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

int main(){
  
  while(1){
    
    int a;
    
    cin>>a;
    
    if(a == -1) break;
    
    if(a<=10){
      cout<<4280-1150<<endl;
    }else if(a<=20){
      cout<<4280-1150-(a-10)*125<<endl;
    }else if(a<=30){
      cout<<4280-1150-10*125-(a-20)*140<<endl;
    }else{
      cout<<4280-1150-10*125-10*140-(a-30)*160<<endl;
    }
    
  }
  return 0;
}



Measured memory_bytes: 2984
def time():
    time_h, time_m = map(int, input().split(":"))
    short = time_m / 60 * 360
    long = time_h * 30 + (time_m / 60 * 30)
    judge = min(abs(short - long), 360 - abs(short - long))
    if 0 <= judge < 30:print("alert")
    elif 30 <= judge < 90:print("warning")
    else:print("safe")
n=int(input())
for i in range(n):time()


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p.at(i);
  }
  sort(p.begin(), p.end());
  int res = 0;
  for (int i = 0; i < K; i++) {
    res += p.at(i);
  }
  cout << res << endl;
}

Measured memory_bytes: 3600
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/pending/disjoint_sets.hpp>
#include <atcoder/all>

#define REPI(i, S, N) for(int i=int(S); i<int(N); i++)
#define REP(i, N) REPI(i, 0, N)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
using mint = atcoder::modint1000000007;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> N,M;
  bst::disjoint_sets_with_storage<> AB(N+1);
  REP(i, M){
    int A, B;
    cin>>A>>B;
    AB.union_set(A, B);
  }
  unordered_set<int> r;
  
  REP(i, N)
    r.insert(AB.find_set(i+1));


  return r.size()-1;
}

template<typename T> void plot(const T& func) { cout << setprecision(9) << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 7480
#include<stdio.h>
#include<math.h>
#define N 10001


int main(){
  int p[N],n,count=0,f[N],a=0;
  int i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++)
  scanf("%d",&p[i]);

  
  for(i=0;i<n;i++){
    for(j=2;j<=sqrt(p[i]);j++){
      if(p[i]%j==0){
	a++;
      break;
      }
    }
  }
  /* for(i=0;i<n;i++){
    if(f[i]==0)
      count++;
  }
  */
  count=n-a;
  
printf("%d\n",count);

  
return 0;
 
}



Measured memory_bytes: 2088
n,k=map(int,input().split())
l=[]
n_l=[]
for i in range(1,n+1):
    n_l.append(i)
#print(n_l)
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for a_j in a:
        l.append(a_j)
l=list(set(l))    
#print(l)
ans=len(list(set(n_l)-set(l)))
print(ans)


Measured memory_bytes: 9192
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; const ll MM = 1000000000;ll mod = MM + 7;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
    int n; cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    rep(i, n) {
        if(a[i] %2 == 0 ) {
            if(a[i] % 3 != 0 && a[i] % 5 != 0) {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

#define int ll
class union_find {
private:
    vector<int> parent;
public:
    union_find(int n) : parent(n, -1) {}
    ~union_find() {}
    void link(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (parent[x] > parent[y])
            swap(x, y);
        parent[x] += parent[y];
        parent[y] = x;
    }
    int find(int x) {
        if (parent[x] < 0)
            return x;
        return parent[x] = find(parent[x]);
    }
    int count(int x) {
        return -parent[find(x)];
    }
    bool linked(int x, int y) {
        return find(x) == find(y);
    }
};

signed main()
{
    int N, M; cin >>N>>M;
    vector<int> A(M), B(M);
    rep(i, M) cin >> A[i] >> B[i];

    union_find uf(N+1);
    vector<ll> ans;
    ans.push_back(N*(N-1)/2);
    for (int i = M-1; i >= 0; i--) {
        if (uf.linked(A[i], B[i])) {
            ans.push_back(ans.back());
        } else {
            ll ca = uf.count(A[i]);
            ll cb = uf.count(B[i]);
            ans.push_back(ans.back()-ca*cb);
            uf.link(A[i], B[i]);
        }
    }
    for (int i = M-1; i >= 0; i--) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 4596
let bits = 60

let () = Scanf.scanf "%d %d\n" @@ fun n k ->
  let as_ =
    Array.to_list @@
    Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  let ls = Array.init bits @@ fun i ->
    List.length @@ List.filter (fun a -> 0 < (a land (1 lsl i))) as_ in
  let rs = Array.init bits @@ fun i ->
    List.length @@ List.filter (fun a -> 0 = (a land (1 lsl i))) as_ in
  Printf.printf "%d\n" @@ 
  Array.fold_left max
    (Array.fold_left ( + ) 0 @@ Array.init bits @@ fun i ->
      ( * ) (1 lsl i) @@
      if k land (1 lsl i) = 0
      then ls.(i)
      else max ls.(i) rs.(i)) @@
    Array.init bits @@ fun i ->
      if k land (1 lsl i) = 0
      then 0
      else Array.fold_left ( + ) 0 @@ Array.init bits @@ fun j ->
        ( * ) (1 lsl j) @@
        if k land (1 lsl j) = 0 && i < j || i = j
        then ls.(j)
        else max ls.(j) rs.(j)



Measured memory_bytes: 15772
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> hw(h, vector<char>(w));
    rep(i, h) rep(j, w) cin >> hw[i][j];
    int dy[4] = {1, -1, 0, 0};
    int dx[4] = {0, 0, 1, -1};
    rep(i, h) rep(j, w) {
        if (hw[i][j] != '#') continue;
        bool ok = false;
        rep(k, 4) {
            int y = i + dy[k];
            int x = j + dx[k];
            if (y < 0 || y >= h || x < 0 || x >= w) continue;
            if (hw[y][x] == '#') ok = true;
        }
        if (!ok) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		if(a>b){
			System.out.println(a-1);
		}else {
			System.out.println(a);
		}
	}
}

Measured memory_bytes: 21972
// Karm Karta ja, Phal Ki Chinta na Kar:)
#include <bits/stdc++.h>
using namespace std;
#include<stdio.h>
typedef long long int ll;
#define INF 1e18+3
#define M 1000000007
#define PI 3.14159265358979323846
int main()
{
   int a,b,c;
   cin>>a>>b>>c;
   if(a+b+c>=22)
    cout<<"bust";
   else
    cout<<"win";
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define endl "\n"
#define loop(i,s,e) for(int i=s;i<e;i++)
#define int long long
#define mp make_pair
#define pii pair<int,int>
#define mset(a,f)  memset(a , f , sizeof(a))
#define pb push_back
const int N = 2e6 + 6;
const int inf = 1e18;
const int M = 1e9 + 7;
int A[N];
int n;

void solve()
{
      int n;
      cin >> n;

      int s = 0;

      loop(i,1,n+1)
      {
            if(i%3 != 0&& i%5 != 0)
            {
                  s += i;
            }
      }

      cout << s;
}
 
int32_t main()
{
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
    

       int t = 1;
       // cin >> t;
       while(t--)solve();
  
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  int s[n];
  for(int i=0;i<n;i++) cin>>s[i];
  int q;
  cin>>q;
  int t[q];
  for(int i=0;i<q;i++) cin>>t[i];
  int ans=0;
  for(int i=0;i<q;i++){
    int l=0,r=n;
    while(l+1<r){
      int m=(l+r)/2;
      if(s[m]<=t[i]) l=m;
      else r=m;
    }
    if(s[l]!=t[i]) continue;
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4244
#!/usr/bin/env python3
import numpy as np

N, M, X = map(int, input().split())
d = []
money = []

for _ in range(N):
    tmp = list(map(int, input().split()))
    money.append(tmp[0])
    d.append(np.array(tmp[1:]))

ans = 10 ** 9
for i in range(1, 2 ** N + 1):
    bought = []
    okane = 0
    for k in range(N):
        if i >> k & 1 == 1:
            bought.append(d[k])
            okane += money[k]
    total = np.zeros(M)
    for j in bought:
        total += j
    if sum(total >= X) == M:
        ans = min(ans, okane)

if ans != 10 ** 9:
    print(ans)
else:
    print(-1)



Measured memory_bytes: 27236
s = input()
q = int(input())
qs = [input().split() for i in range(q)]
n = False
left= right = ""
for operation in qs:
    if operation[0] == '1':
        n = not n
    if operation[0] == '2':
        t , f, c = operation
        f = int(f)
        if n:
            f = 1 if f != 1 else 2
        if f == 1:
            left=c+left
        elif f == 2:
            right+=c
s = left+s+right
print(s[::-1] if n else s)

Measured memory_bytes: 40640
n,x,y=map(int,input().split())
x,y=x-1,y-1
ans=[0]*(n+1)
for i in range(n):
    for j in range(i+1,n):
        ans[min(j-i,abs(x-i)+abs(y-j)+1)]+=1
for i in range(1,n):
    print(ans[i])

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

using ll = long long;
//print(fixed << setprecision(10));
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define repk(i,n,k) for(ll i = k; i < (n); i++)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl
double PI = acos(-1.0);
int INF = 1e9;
ll LINF = 1e18;
ll MOD = 1e9+7;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    ll n,sum=0;
    cin >> n;
    for(ll i=1;i<=n/2;i++){
        sum += (n-1)/i;
    }
    sum+=(n-1)/2;
    print(sum);
    return 0;
}

Measured memory_bytes: 3612
import java.util.Scanner;
//import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int count = 3;
		if(a == b) count--;
		if(a == c) count--;
		if(b == c) count--;
		if(count == 0) count = 1;
		System.out.println(count);
	}
}


Measured memory_bytes: 35684
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))

int main(){
    ll ans=0,n,k;
    cin >>n>>k;
    ans=(n>=k)?((n%k>0)?1:0):1;
    cout <<ans<<endl;

    return 0;

}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    int N=sc.nextInt();
    boolean buyflg=false;
    
    for(int a=0; a<=N/7; a++){
      
	  for(int b=0; b<=N/4; b++){
        if(a*7+b*4==N){
          buyflg=true;
          break;
        }
      }
      if(buyflg==true){
        break;        
      }
    }
    String outstr = buyflg==true ? "Yes":"No";
    System.out.println(outstr);
  }
}

Measured memory_bytes: 23636
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
using namespace std;

int main()
{
	int w, h;
	char c;
	cin >> w >> h >> c;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if ((i == 0 && j == 0 ) || (i == 0 && j == (w - 1)) || (i == (h - 1) && j == 0) || (i == (h - 1) && j == (w - 1))) {
				cout << "+";
			}
			else if (i == 0 || i == (h - 1)) {
				cout << "-";
			}
			else if (j == 0 || j == (w - 1)) {
				cout << "|";
			}
			else if (i == (h / 2) && j == (w / 2)) {
				cout << c;
			}
			else {
				cout << ".";
			}
		}
		cout << endl;
	}
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
char aa[1005][1005];
int dist[1005][1005];
vector<int> dx={1,0,0,-1};
vector<int> dy={0,1,-1,0};
int main() {
	int h,w;
	cin >> h >> w;
	queue<pair<int,int>> que;
	pair<int,int> a;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin >> aa[i][j];
			if(aa[i][j]=='.')dist[i][j]=-1;
			else{
				dist[i][j]=0;
				a.first=i;
				a.second=j;
				que.push(a);
			}
		}
	}
	while(!que.empty()){
		pair<int,int> v;
		v=que.front();
		que.pop();
		for(int i=0;i<4;i++){
			int nx=v.first+dx[i];
			int ny=v.second+dy[i];
			if(nx<0||nx>=h||ny<0||ny>=w) continue;
			if(dist[nx][ny]!=-1) continue;
			dist[nx][ny]=dist[v.first][v.second]+1;
			pair<int,int> nv;
			nv.first=nx;
			nv.second=ny;
			que.push(nv);
		}
	}
	int ans=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			ans=max(ans,dist[i][j]);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 13328
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top,S[1000];

void push(int x){

S[++top]=x;
}
int pop(){
top--;
return S[top+1];
}

int main(){
int a,b;
top=0;
char s[100];
while(scanf("%s",s)!=EOF){
if(s[0]=='+'){
a=pop();
b=pop();
push(a+b);
}else if(s[0]=='-'){
b=pop();
a=pop();
push(a-b);
}else if(s[0]=='*'){
a=pop();
b=pop();
push(a*b);
}else{
push(atoi(s));
}
}
printf("%d\n",pop());
return 0;
}

Measured memory_bytes: 980
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
ll n;
ll a[5];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i=0;i<5;i++) cin>>a[i];
    ll ans=4;
    sort(a,a+5);
    ll sec;
    if(n%a[0]!=0) sec=n/a[0]+1;
    else sec=n/a[0];
    ans+=sec;
    cout <<ans<< "\n";
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n;
	cin>>n;
	n*=2;
	vint v(n);
	rep(i,n) cin>>v[i];
	sort(ALL(v));
	reverse(ALL(v));
	int ans = 0;
	rep(i,n){
		if(i==n-1) continue;
		ans += v[i+1];
		i++;
	}
	cout<<ans<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		int n,m,gcd,reminder;
		n = Math.min(a, b);
		m = Math.max(a, b);
		while(true) {
			if( m % n != 0) {
				reminder = m % n;
				m = n;
				n = reminder;
			}else {
				gcd = n;
				break;
			}
		}
		
		System.out.println((long)a * (long)b / (long)gcd);
	}
}

Measured memory_bytes: 23508
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

int main(){

    
    cin >> A;
    ll cnt = 0;
    ll money = 100;
    while(money<A){
        cnt++;
        money = money + money * 0.01;

    }
    cout << cnt << endl;

    

}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ULL unsigned long long
#define LL long long
#define LD long double
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz(x) (int)(x).size()
#define all(x) x.begin(),x.end()
#define loop(i,a,b) for(int i=a;i<=b;++i)
#define pool(i,a,b) for(int i=a;i>=b;--i)
#define int long long
using namespace std; const int N = 300000 + 5, N2 = 50000 + 5, LOG = 9 + 1, INF = 1e9;

int a[N]; pair<int,int> que[N];

signed main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string s; cin>>s;
	if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]) cout<<"Bad\n";
	else cout<<"Good\n";
}


Measured memory_bytes: 256
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N = Z()
    s = input()
    a, b = [0], [0]
    for i in range(N):
        if s[i] == '#': a.append(a[-1]+1)
        else: a.append(a[-1])

        if s[-1-i] == '.': b.append(b[-1]+1)
        else: b.append(b[-1])
    b = b[::-1]
    output =  10 ** 6
    for x, y in zip(a, b): output = min(output, x + y)
    print(output)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 14600
/** 
 * THIS IS MOOONI'S CODE !
 * HACK IT IF YOU CAN !
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<string> v;
  v.push_back("a");
  vector<int> mx;
  mx.push_back(0);
  for (int i = 1; i < n; i++) {
    vector<string> new_v;
    vector<int> new_mx;
    for (int j = 0; j < (int) v.size(); j++) {
      string s = v[j];
      char c = s[(int) s.size() - 1];
      for (int jj = 0; jj <= min(25, mx[j] + 1); jj++) {
        string t = s + (char) (jj + 'a');
        new_v.push_back(t);
        new_mx.push_back(max(mx[j], jj));
      }
    }
    swap(v, new_v);
    swap(mx, new_mx);
  }
  sort(v.begin(), v.end());
  for (auto& s : v) {
    cout << s << '\n';
  }
  return 0;
}

Measured memory_bytes: 11468
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace __gnu_pbds;
using namespace std;
//typedef
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
//constants
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
// gcd of a and b
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
// distance between (a,b) and (c,d)
long double dis(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
// simple prime check
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
// fast expo
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
// modular inverse
ll minv(ll a,ll mod){
	ll _gcd=gcd(a,mod);
	assert(_gcd==1);
	return mpow(a,mod-2,mod);
}

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*
ll dx[]={1,0,-1,0,1,1,-1,-1};
ll dy[]={0,-1,0,1,1,-1,-1,1};
*/

/*
void sieve(int N){
	for(int i=0;i<=N;i++){
		spf[i]=i;
	}
	for(int i=2;i*i<=N;i++){
		if(spf[i]==i){
			for(int j=i*i;j<=N;j+=i){
				spf[j]=min(spf[j],i);
			}
		}
	}
	return;
}
*/

/*
void nCr(ll n,ll k){
	ll i,j;
	for(i=0;i<=n;i++){
		for(j=0;j<=min(i,k);j++){

			if(j==0 or j==i)C[i][j]=1LL;
			else  C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;

		}
	}
	return;
}
*/
/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
ll dp[2005][2005];
ll n,m;
ll a[2005],b[2005];
int main(){FAST;
cin>>n>>m;
for(ll i=0;i<n;i++)cin>>a[i];
for(ll j=0;j<m;j++)cin>>b[j];
for(ll i=1;i<=n;i++){
	for(ll j=1;j<=m;j++){
		if(a[i-1] == b[j-1]){
			dp[i][j]=(((dp[i-1][j]+dp[i][j-1])%MOD)+1)%MOD;
		}
		else{
			dp[i][j] = (((dp[i-1][j]+dp[i][j-1])%MOD)-dp[i-1][j-1]+MOD)%MOD;
		}
	}
}
cout<<dp[n][m]+1;
return 0;
}

Measured memory_bytes: 31616
import sys

A = [ int(x) for x in input().split(" ")]
A += [ int(x) for x in input().split(" ")]
A += [ int(x) for x in input().split(" ")]
N = int(input())
b = [None]*N
for i in range(N):
    b[i] = int(input())

Ans = [-1000]*9

for i in range(len(A)):
    for bb in b:
        if bb==A[i]:
            Ans[i] = bb
            break

if(0<=Ans[0]+Ans[1]+Ans[2]):
    print("Yes")
    exit(0)
if(0<=Ans[3]+Ans[4]+Ans[5]):
    print("Yes")
    exit(0)
if(0<=Ans[6]+Ans[7]+Ans[8]):
    print("Yes")
    exit(0)
if(0<=Ans[0]+Ans[3]+Ans[6]):
    print("Yes")
    exit(0)
if(0<=Ans[1]+Ans[4]+Ans[7]):
    print("Yes")
    exit(0)
if(0<=Ans[2]+Ans[5]+Ans[8]):
    print("Yes")
    exit(0)
if(0<=Ans[0]+Ans[4]+Ans[8]):
    print("Yes")
    exit(0)
if(0<=Ans[2]+Ans[4]+Ans[6]):
    print("Yes")
    exit(0)
print("No")

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

int main() {
	int mizu,kane,sa;
	kane=0;
	int n=1;
	while(n){
		
		cin >> mizu;
		
		if(mizu==-1) break;
		if(mizu>10 && mizu<=20){
			mizu=mizu-10;
			kane=1150+mizu*125;
		}else if(mizu>20 && mizu<=30){
			mizu=mizu-20;
			kane=1150+1250+mizu*140;
		}else if(mizu<=10){
			kane=1150;
		}else if(mizu>30){
			mizu=mizu-30;
			kane=1150+1250+1400+(mizu*160);
		}
		n++;
		cout << 4280-kane << endl;
		}
	
	return 0;
}

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

//def
#define debug(x) cout << #x << ": " << x << '\n'
#define out(x) cout << x << '\n'
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

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

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

    string s;
    cin >> s;
    int n = s.size();
    auto judge = [&]() {
        if (s.size() % 2) return false;

        int half = s.size() / 2;
        rep(i, half) {
            if (s[i] != s[i + half]) return false;
        }

        return true;
    };

    rep(i, n) {
        s.erase(s.end() - 1);
        if (judge()) {
            out(s.size());
            return 0;
        }
    }
}


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

int main()
{
    ll N = 50;
    ll K;
    scanf("%lld", &K);
    ll ans[N];
    for(ll i = 0; i < N; ++i) ans[i] = i + K/N;
    K %= N;
    for(ll i = 0; i < K; ++i) {
        ans[0] += N;
        for(ll j = 1; j < N; ++j) ans[j] -= 1;
        sort(ans, ans + N);
    }
    printf("%lld\n", N);
    for(ll i = 0; i < N; ++i) printf("%lld ", ans[i]);
    printf("\n");
    return 0;
}

Measured memory_bytes: 384
N = int(input())
dic = {}
for i in range(N):
  s = input()
  if s not in dic:
    dic[s] = 1
  else:
    dic[s] += 1
M = int(input())
for i in range(M):
  s = input()
  if s not in dic:
    dic[s] = -1
  else:
    dic[s] -= 1
lst = list(dic.values())
lst.append(0)
print(max(lst))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    if(s[0] == t[2] && s[1] == t[1] && s[2] == t[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256