akhauriyash/Code-Regression huggingface dataset:
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define REP(i, n) for(int i = 0;i < (n);i++)
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=998244353 ;
const llint inf=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	int a[]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int K;cin>>K;
	cout<<a[K]<<endl;
}

Measured memory_bytes: 256
/*
the top of the losers
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    Lcm(a,b)  ((a*b)/(__gcd(a,b)))
#define    X            real()
#define    Y            imag()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define     point        complex<ll>
#define    cp(a,b)          (((conj(a))*(b)).imag())
typedef  long long     ll ;
typedef  unsigned long long     ull ;
const double eps= (1e-9);
using namespace std;
using namespace __gnu_pbds;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
ll a[59];
int main(){
    GO();
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll ss=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ss+= a[i]*a[j];
        }
    }
    cout<<ss<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pb() push_back()
#define INF 1000000000
using namespace std;
map<int,int> prime;
void primeFactors(ll n)  {  
    while (n % 2 == 0)  
    {  
		prime[2]++;
        n = n/2;  
    }  
  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        while (n % i == 0)  
        {  
			prime[i]++;
            n = n/i;  
        }  
    }  
    if (n > 2) prime[n]++; 
        
}
const int mod = 1e9+7;
int main(){
	ll x;
	cin>>x;
	primeFactors(x);
	int sum = 0;
	for(auto &a: prime){
		sum += floor((sqrt(1+8*a.second)-1)/2);
	}
	cout<<sum<<endl;
		return 0;
}


Measured memory_bytes: 3664
S = input()
acgt = ['A','C','G','T']
for base in acgt:
    S = S.replace(base, ' ')
S += 'E'
maxlen = 0;
count = 0;
for w in S:
    if w == ' ':
        count += 1
    else:
        if count > maxlen:
            maxlen = count
        count = 0
print(maxlen)

Measured memory_bytes: 3060
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector> 
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
const int inf=1e9+7;
char s[maxn];
int a[maxn],b[maxn];
 
 
 int main(){
 	int n;
 	scanf("%d",&n);
 	int rank1=inf,rank2=-inf,score;
 	for(int i=1;i<=n;i++){
 		scanf("%d%d",&a[i],&b[i]);
 		if(a[i]<rank1) rank1=a[i];
 		if(a[i]>rank2) rank2=a[i],score=b[i];
	 }
	 printf("%d\n",rank2-rank1+1+(rank1-1)+score-0);
 	return 0;
 }
 
 /*
 
 int main(){
	scanf("%s",s);
	int ans=0;
	for(int i=0;i<=5;i++){
		if(s[i]=='1') ans++;
	}
	printf("%d\n",ans); 
	return 0;
} 
*/


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

vector<int> memo(100100);
vector<int> a, b;
int h, n;
int dp(int x) {
    if (x <= 0) {
        return 0;
    }
    if (memo[x] != -1) {
        return memo[x];
    }
    int ret = INF;
    rep(i, n) {
        chmin(ret, dp(x - a[i]) + b[i]);
    }
    return memo[x] = ret;
}

int main() {
    cin >> h >> n;
    a.resize(n);
    b.resize(n);
    rep(i, n) cin >> a[i] >> b[i];
    rep(i, 100100) memo[i] = -1;
    cout << dp(h) << endl;
}


Measured memory_bytes: 1152
#include<iostream>
#include<math.h>
#include<set>
#include<string.h>
#define ll long long
using namespace std;


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

  ll A[N]={};
  ll B[N]={};
  for(ll i=0; i<N; i++){
    cin >> A[i];
    A[i]--;
    B[i] = -1;
  }

  ll now=0;
  B[now] = 0;

  ll time=1;
  ll roop_start = 0;
  for(;time<=K;time++){
    now = A[now];
    //cout << "now:" << now << endl;
    if(B[now] != -1){
      roop_start = B[now];
      break;
    }
    B[now] = time;
    if(time == K) roop_start=-1;
  }

  ll target;
  //cout << "K:" << K << " roop_start:" << roop_start << " time:" << time << endl;
  if(roop_start<0) target= K;
  else{
    if(K <= roop_start) target = K;
    else target =((K-roop_start) % (time-roop_start)) + roop_start ;
  }
  //cout << "target:" << target << endl;
  now =0;
  for(ll i=1;i<=time;i++){
    if(B[now] == target){
      cout << now+1 << endl;
      return 0;
    }
    now = A[now];
  }

  cout << "something wrong"  << now+1<< endl;
  return 0;
}

Measured memory_bytes: 6756
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const ll inf = 1e18;

int main() {
    int n;
    cin >> n;
    bool ok = false;
    while (n > 0) {
        if (n % 10 == 7) ok = true;
        n /= 10;
    }
    printf(ok?"Yes\n":"No\n");
}

Measured memory_bytes: 3660
#include <algorithm>
#include <numeric>
#include <map>
#include <vector>
#include <iostream>

using namespace std;
int sum[5200][5200];

template <typename T,typename Func>
	T satisfy_min(Func P,T l ,T r,T eps){
		while(r-l>eps){
			T m=(l+r)/2;
			(P(m)?r:l)=m;
		}
		return r;
	}


int main() {
	
		int n, m;
		scanf("%d%d", &n, &m);
		
		for (int i = 0; i < 5200; i++) {
			for (int j = 0; j < 5200; j++) {
				sum[i][j] = 0;
			}
		}

		int x[n], y[n];
		vector<int> xs, ys;
		xs.push_back(-1100000000);
		ys.push_back(-1100000000);
		for (int i = 0; i < n; i++) {
			cin >> x[i];
			cin >> y[i];
			xs.push_back(x[i]);
			ys.push_back(y[i]);
		}
		xs.push_back(1100000000);
		ys.push_back(1100000000);
		sort(xs.begin(), xs.end());
		sort(ys.begin(), ys.end());
		xs.erase(unique(xs.begin(), xs.end()), xs.end());
		ys.erase(unique(ys.begin(), ys.end()), ys.end());

		for (int i = 0; i < n; i++) {
			int nx = lower_bound(xs.begin(), xs.end(), x[i]) -xs.begin();
			int ny = lower_bound(ys.begin(), ys.end(), y[i]) -ys.begin();
			sum[nx][ny]++;
		}

		for (int i = 1; i < 5200; i++) {
			for (int j = 1; j < 5200; j++) {
				sum[i][j] += sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];
			}
		}

		for (int i = 0; i < m; i++) {
			int x1, y1, x2, y2;
			scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
			int nx2 = upper_bound(xs.begin(), xs.end(), x2) -xs.begin();
			int nx1 = lower_bound(xs.begin(), xs.end(), x1) -xs.begin();
			int ny2 = upper_bound(ys.begin(), ys.end(), y2) -ys.begin();
			int ny1 = lower_bound(ys.begin(), ys.end(), y1) -ys.begin();
			nx2--; ny2--;
			ny1--; nx1--;
			printf("%d\n", sum[nx2][ny2]-sum[nx2][ny1]-sum[nx1][ny2]+sum[nx1][ny1]);
		}
	
}

Measured memory_bytes: 106976
#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long int
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define vv(type)		vector<vector<type>>
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define db(x) 			cout<<x<<" "
#define db1(x) 			cout<<x<<'\n'
#define db2(x,y) 		cout<<x<<" "<<y<<'\n'
#define db3(x,y,z) 		cout<<x<<" "<<y<<" "<<z<<'\n'
#define rep(i,n) 		for(int i=0;i<(n);++i)
#define repA(i,a,n) 	for(int i=a;i<=(n);++i)
#define repD(i,a,n) 	for(int i=a;i>=(n);--i)
#define so(a) 			sort(a.begin(),a.end())
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
// to find all local maximaa and minima in O(n)
//	 for (int i=1;i<=n;i++)
//        {
//            if (i==1 || i==n || (p[i-1]<p[i])!=(p[i]<p[i+1]))
//           ans.push_back(p[i]);
//        }
int dx[] = { -1, 1, -1, 0, 0, -1, 1, 1 };
int dy[] = { -1, -1, 1, -1, 1, 0, 0, 1 };
int gcd(int a, int b)
{
	if (!b)
		return a;
	return gcd(b, a % b);
}
int modular_expo(int x, int y, int m)
{
	int ans = 1;
	while (y)
	{
		if (y & 1)
			ans = (ans % m * x % m) % m;
		x = (x % m * x % m) % m;
		y /= 2;
	}
	return ans % m ;
}
int power(int x, int y)
{
	int ans = 1;
	while (y)
	{
		if (y & 1)
			ans = (ans * x);
		x *= x;
		y /= 2;
	}
	return ans;
}

void solve()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, k;
	cin >> n >> k;
	vi a(n);
	rep(i, n)
	cin >> a[i];
	int dp[k + 1];
	memset(dp, 0, sizeof(dp));
	rep(i, k + 1)
	{
		rep(j, n)
		{
			if (i - a[j] >= 0 && dp[i - a[j]] == 0)
				dp[i] = 1;
		}
	}
	if (dp[k])
		db1("First");
	else
		db1("Second");
}
int32_t main()
{
	solve();
	return 0;
}


Measured memory_bytes: 4388
#include<iostream>
    using namespace std;
    int main(){
    	int n;
    	cin>>n;
    	long long int sum=0;
    	int a[200000];
    	for(int i=0;i<n;i++){
    		cin>>a[i];
    		sum+=a[i];
    	}
    	sum-=a[n-1];
    	long long int k=a[n-1];
    	long long int min=abs(sum-k);
    	for(int i=n-2;i>0;i--){
    		sum-=a[i];
    		k+=a[i];
    		if(abs(sum-k)<min){
    			min=abs(sum-k);
    		}
    		
    	}
    	cout<<min;
    	cin>>min;
    }

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

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

  char ju = a[0];
  a.erase(a.begin()+0);

  while(1) {
    if(ju == 'a') {
      if(a.empty()) {
        cout << 'A';
        return 0;
      }
      ju = a[0];
      a.erase(a.begin()+0);
    }else if(ju == 'b') {
      if(b.empty()) {
        cout << 'B';
        return 0;
      }
      ju = b[0];
      b.erase(b.begin()+0);
    }else if(ju == 'c') {
      if(c.empty()) {
        cout << 'C';
        return 0;
      }
      ju = c[0];
      c.erase(c.begin()+0);
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin>>s;
	int a=200000,z;
	for(int i=0;i<s.size();i++){
		if(s[i]=='A'&&i<a){
			a=i;
		}
		else if(s[i]=='Z'){
			z=i;
		}
	}
	cout<<z-a+1<<endl;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()

const int MOD = 1e9+7;
const int MAX = 1e5+10;

ll fac[MAX<<2];
ll finv[MAX<<2];
ll inv[MAX<<2];

void init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    FOR (i, 2, MAX<<2) {
        fac[i] = fac[i-1]*i % MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i) % MOD;
        finv[i] = finv[i-1]*inv[i] % MOD;
    }
}

ll nCk (int n, int k) {
    if (n < k || k < 0 || n < 0) return 0;
    return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

int N, K;
vi A;

int solve() {
    sort(ALL(A));
    ll mx = 0, mn = 0;

    REP (i, N) {
        mx = (mx + A[i] * nCk(i, K-1)) % MOD;
        mn = (mn + A[i] * nCk(N-i-1, K-1)) % MOD;
    }

    return (mx + MOD - mn) % MOD;
}

int main() {
    init();
    cin >> N >> K;
    REP (i, N) {
        int a;
        cin >> a; A.push_back(a);
    }
    cout << solve() << endl;
}

Measured memory_bytes: 10744
#include<map>
#include<queue>
#include<time.h>
#include<limits.h>
#include<cmath>
#include<ostream>
#include<iterator>
#include<set>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define rep_1(i,m,n) for(int i=m;i<=n;i++)
#define mem(st) memset(st,0,sizeof st)
int read()
{
	int res=0,ch,flag=0;
	if((ch=getchar())=='-')             //判断正负
		flag=1;
	else if(ch>='0'&&ch<='9')           //得到完整的数
		res=ch-'0';
	while((ch=getchar())>='0'&&ch<='9')
		res=res*10+ch-'0';
	return flag?-res:res;
}
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef pair<double,double> pdd;
const int inf = 0x3f3f3f3f;
#define int long long
char s[1000005];
signed main()
{
	cin>>s+1;
	int len=strlen(s+1);
	for(int i=1;i<=len;i++)
	{
		if(s[i]=='?')
			cout<<"D";
		else
			cout<<s[i];
	}
	return 0;
}


Measured memory_bytes: 3760
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

ans = sum(b)
for i, j in zip(a[:-1], a[1:]):
    if j == i + 1:
        ans += c[i - 1]
print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int inf=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;

int main(){
  ll n,m,q;cin>>n>>m>>q;
  vll a(q),b(q),c(q),d(q),A(10);
  rep(i,0,q){
    cin>>a[i]>>b[i]>>c[i]>>d[i];
    a[i]--;b[i]--;
  }
  ll ans=0;
  rep(i,1,m+1){
    A[0]=i;
    rep(j,i,m+1){
      A[1]=j;
      rep(k,j,m+1){
        A[2]=k;
        rep(l,k,m+1){
          A[3]=l;
          rep(x,l,m+1){
            A[4]=x;
            rep(y,x,m+1){
              A[5]=y;
              rep(z,y,m+1){
                A[6]=z;
                rep(w,z,m+1){
                  A[7]=w;
                  rep(u,w,m+1){
                    A[8]=u;
                    rep(v,u,m+1){
                      A[9]=v;
                      ll tmp=0;
                      rep(t,0,q){
                        if(A[b[t]]==(A[a[t]]+c[t])){
                          tmp+=d[t];
                        }
                      }
                      ans=max(ans,tmp);
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
  }
}init;


int main(){
  int n;
  while(cin >> n){
    bool ans = false;
    
    FORE(i,1,9){
      FORE(j,1,9){
        if(n == i*j){
          ans = true;
        }
      }
    }

    cout << (ans ? "Yes" : "No") << endl;


    
  }

  return 0;
}


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

int main(){
	int n;
  	cin >> n;
  	
  	while(n > 1000){
    	n -= 1000;
    }
  
  	cout << 1000 - n << endl;
}

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



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

    
    int s,w; cin >> s>> w;
    if( w>=s) cout << "unsafe" << endl;
    else cout << "safe" << endl;
}

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

int main() {
    // input
    int N, M;
    cin >> N >> M;
    char A[N][N];
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            cin >> A[i][j];
        }
    }
    char B[M][M];
    for (int i = 0; i < M; ++i) {
        for (int j = 0; j < M; ++j) {
            cin >> B[i][j];
        }
    }

    // solve
    bool flag = false;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            bool match = true;
            for (int k = 0; k < M; ++k) {
                for (int l = 0; l < M; ++l) {
                    if (A[i + k][j + l] != B[k][l]) match = false;
                }
            }
            if (match) flag = true;
        }
    }

    // output
    cout << (flag ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(input){
    var line = input.trim().split("\n");
    var i = 0;
    while(line[i] !== '0')
    {
        var N = parseInt(line[i++].trim());
        {
            var found, res;
            var qualified = [], amount = [];
            for(--N;N>=0;--N){
                var dataset = line[i++].trim().split(" ");
                res = parseInt(dataset[1]) * parseInt(dataset[2]);
                
                for(k=0;k<qualified.length;++k){
                    if(qualified[k] == dataset[0]){
                        amount[k] += res;
                        break;
                    }
                }
                
                if( k >= qualified.length ){
                    qualified.push(dataset[0]);
                    amount.push(res);
                }
            }
            
            found = 0;
            for(k=0;k<qualified.length;++k){
                if( amount[k] >= 1000000 ){
                    console.log(qualified[k]);
                    found = 1;
                }
            }
            if( !found ){
                console.log("NA");
            }
        }
    }
});

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


priority_queue<int> p;


int main(void){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> jobs(m);
    
    rep(i,n){
        int a,b;
        cin >> a>> b;
        if(a>m)continue;
        jobs[m-a].push_back(b);
    }
    priority_queue<int> q;
    ll ans = 0;
    for(int i=m-1;i>=0;i--){
        for(int b:jobs[i]){
            q.push(b);
        }
        if(!q.empty()){
            ans += q.top();
            q.pop();
        }
    }
    
    cout << ans << endl;
    
    return 0;
}





Measured memory_bytes: 5504
<?php
    $inputs = array(
        -1 => 'a < b',
        0  => 'a == b',
        1  => 'a > b',
    );
    fscanf(STDIN, '%d %d', $a, $b);
    
    echo $inputs[cmp($a, $b)], PHP_EOL;
    
    function cmp($a, $b)
    {
        if ($a == $b) { return 0; }
        
        return ($a < $b) ? -1 : 1;
    }

Measured memory_bytes: 6572
#include <stdio.h>
#include <math.h>
 
int square(int x) {
    return x * x;
}
 
int main() {
    int n, town[9][2];
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d %d", &town[i][0], &town[i][1]);
    }
    double ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            ans += sqrt( square(town[i][0] - town[j][0]) + square(town[i][1] - town[j][1]) );
        }
    }
    ans = ans * 2 / n;
    printf("%.16f", ans);
}

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

using namespace std;
using ll=long long;
const ll mod = 1e9 + 7;
const ll INF = 1LL<<60;

int main() {
    int N,M;
    cin>>N>>M;
    vector<pair<int,ll>> tonari[1001];
    for(int i = 0; i < M; ++i) {
        int a,b; ll w;
        cin>>a>>b>>w;
        tonari[a-1].push_back({b-1,-w});
    }

    bool heikei=false;
    vector<ll> dist(N,INF);
    dist[0]=0;
    for(int i=0;i<=2*N;i++){
        for(int v=0;v<N;v++) {
            if (dist[v] >= INF/2) continue;
            for (auto next:tonari[v]) {
                if (dist[next.first] > dist[v] + next.second) {
                    dist[next.first] = dist[v] + next.second;
                    if (next.first == N - 1 &&i==2*N) heikei=true;
                }
            }
        }
    }
    if(heikei) cout<<"inf"<<endl;
    else cout<<-dist[N-1]<<endl;

    return 0;
}



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

void solve() {
   

   string s;
   cin>>s;
   string t;
   cin>>t;
     int mini=INT_MAX;

     int sl=s.length()-1;
     int tl=t.length()-1;
   for( int i=0;i<=sl-tl;i++ ) {
         int ans=0;
         for(int j=0;j<=tl;j++) {
               if(s[i+j]!=t[j]) ans++;
         }
         mini=min(ans,mini);
   }
   cout<<mini;
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
     freopen("in.txt","r",stdin);
      
     #endif

     int t;
     t=1;
     while(t--) solve();


   return 0;
}


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

using namespace std;

int main(){
	ios_base::sync_with_stdio (false);
	cout << fixed;
	cout.precision(10);
	if(fopen("joke.in", "r")){
		freopen ("joke.in","r",stdin);
		freopen ("joke.out","w",stdout);
	}

	int H, W, K;
	cin >> H >> W >> K;
	vector<string> g(H);
	for(int h = 0; h < H; ++h){
		cin >> g[h];
	}


	int res = 0;
	for(int h = 0; h < (2 << (H - 1)); ++h){
		for(int w = 0; w < (2 << (W - 1)); ++w){
			int cnt = 0;
			for(int row = 0; row < H; ++row){
				for(int col = 0; col < W; ++col){
					if(g[row][col] == '#' &&
					   !(1 == ( (h >> row) & 1)) &&
					   !(1 == ( (w >> col) & 1)) ){
						cnt++;
					}
				}
			}

			if(cnt == K){
				res++;
			}

		}
	}

	cout << res;
    return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
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 ll INF = 1LL << 60;
int main(){
    int n; cin >> n;
    string s,t; cin >> s >> t;
    rep(i,n){
        cout << s[i] << t[i];
    }
    cout << endl;
    return 0;
}

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

ll A, B, C, D;
map<ll, ll> memo;

ll solve(ll N) {
    if (N == 0) return 0;
    if (N == 1) return D;
    if (memo.count(N)) return memo[N];
    ll l2 = (N / 2) * 2;
    ll r2 = ((N + 1) / 2) * 2;
    ll l3 = (N / 3) * 3;
    ll r3 = ((N + 2) / 3) * 3;
    ll l5 = (N / 5) * 5;
    ll r5 = ((N + 4) / 5) * 5;

    ll res = 1e18;
    if (N < res / D) res = N * D;
    res = min(res, llabs(l2 - N) * D + A + solve(l2 / 2));
    res = min(res, llabs(r2 - N) * D + A + solve(r2 / 2));

    res = min(res, llabs(l3 - N) * D + B + solve(l3 / 3));
    res = min(res, llabs(r3 - N) * D + B + solve(r3 / 3));

    res = min(res, llabs(l5 - N) * D + C + solve(l5 / 5));
    res = min(res, llabs(r5 - N) * D + C + solve(r5 / 5));

    memo[N] = res;

    return res;
}

int main() {
    int T;
    cin >> T;
    for (int t = 0; t < T; t++) {
        memo.clear();
        ll N;
        cin >> N;
        cin >> A >> B >> C >> D;
        cout << solve(N) << "\n";
    }
}


Measured memory_bytes: 4476
/*
本宝的程序外人别想看！！

name: [夏宝宝]
run time：[] ms
compilation time: [] ms
output memory: [] MiB
where: []
state: []
*/
#include<bits/stdc++.h>
using namespace std;

inline int read()
{
	int s=0, w=1;

	char ch=getchar();

	while(ch<'0' || ch>'9')
	{
		if(ch='-')
		{
			w=-w;
		}

		ch=getchar();
	}

	while(ch>='0' && ch<='9')
	{
		s=(((s*10ll))+(ch-'0'));

		ch=getchar();
	}

	return s;
}

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	
	cout.sync_with_stdio(false);
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	long long int a, b, c;
	
	a=read();
	b=read();
	c=read();
	
	long long int d=c-a-b;
	
	if(d>0 && d*d>4*a*b)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#   ?????????????????°???????????????????¨??????????????????°??????
while 1:
    #   ?¨??????\???????????°???????????????
    input_num = list(input())
    #   ???????????????"0"??\?????§??????
    if int(input_num[0]) == 0:
        break
    #   print(input_num)
    #   ??????????¨?????????????????????°
    digitTotal = 0
    for i in range(0, len(input_num)):
        digitTotal += int(input_num[i])
    print("{0}".format(digitTotal))

Measured memory_bytes: 7644
#include <stdio.h>

int main()
{
    int x;
    int h, m;
    
    h = 3600;
    m = 60;
    scanf("%d", &x);
    
    printf("%d:%d:%d\n", x/h, (x%h)/m, (x%h)%m);
    
    return 0;
}


Measured memory_bytes: 2052
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>

using namespace std;
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

const int maxn = 5e5;
const int MOD = 1e9 + 7;

class Modint {
public:
	long long val;

	Modint (long long _val = 0)
		: val((_val + MOD) % MOD) {}

	Modint operator+ (Modint other) {
		return Modint(val + other.val);
	}

	void operator+= (Modint other) {
		val += other.val;
		val %= MOD;
	}

	Modint operator- () {
		return Modint(MOD - val);
	}

	Modint operator- (Modint other) {
		return Modint(val + MOD - other.val);
	}

	void operator-= (Modint other) {
		val += MOD - other.val;
		val %= MOD;
	}

	Modint operator* (Modint other) {
		return Modint(val * other.val);
	}

	void operator*= (Modint other) {
		val *= other.val;
		val %= MOD;
	}

	bool operator== (Modint other) {
		return val == other.val;
	}

	bool operator!= (Modint other) {
		return val != other.val;
	}
};

Modint exp (Modint a, int k) {
	if (k == 0) {
		return Modint(1);
	} else if (k % 2 == 0) {
		Modint half = exp(a, k / 2);
		return half * half;
	} else {
		return a * exp(a, k - 1);
	}
}

Modint inv (Modint a) {
	return exp(a, MOD - 2);
}

ostream& operator<< (ostream& out, Modint p) {
	out << p.val;
	return out;
}

vector<Modint> fact(maxn + 1, 1);
vector<Modint> inverse(maxn + 1, 1);

void preC() {
	for (long long i = 1; i <= maxn; i++) {
		fact[i] = Modint(i) * fact[i - 1];
		inverse[i] = inv(i) * inverse[i - 1];
	}
}

Modint C(long long n, long long r) { // nCr % MOD
	if (n < r) return 0;
	return fact[n] * inverse[r] * inverse[n - r];
}

Modint P(long long n, long long r) {
	if (n < r) return 0;
	return C(n, r) * fact[r];
}

int main() {

	preC();
	int n, m; cin >> n >> m;

	Modint ans = 0;
	for (int i = 0; i <= n; i++) {
		ans += (Modint(1 - 2 * (i & 1)) * C(n, i) * P(m, i) * P(m - i, n - i) * P(m - i, n - i));
	}

	cout << ans;
	return 0;
}


Measured memory_bytes: 10680
import heapq

N=int(input())
A=sorted(list(map(int,input().split())), reverse=True)
ans=0
H=[-1*A[0]]
heapq.heapify(H)
for a in A[1:]:
  ans-=heapq.heappop(H)
  heapq.heappush(H,-1*a)
  heapq.heappush(H,-1*a)
print(ans)

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

int A, B;

const int MAX_U = 1000005;
bool used[MAX_U];
vector<int> p;

signed main()
{
  cin >> A >> B;
  int maxGcd = gcd(A, B);

  FOR(n,2,MAX_U) {
    if(used[n]) continue;
    p.push_back(n);
    for(int k = 2; k*n < MAX_U; k++) {
      used[k*n] = true;
    }
  }

  int ans = 1;
  REP(n,p.size()) {
    if(maxGcd%p[n] == 0) {
      ans++;
      while(maxGcd%p[n] == 0) {
        maxGcd /= p[n];
      }
    }
  }
  
  if(maxGcd != 1) {
    ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2424
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
#define ll long long
#define in(a) a=read()
#define out(a) printf("%d\n",a)
inline ll read(){
    char c=getchar();ll f=1,x=0;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+(c-'0'),c=getchar();
    return x*f;
}
#define mod 1000000007
void MOD(int &x){if(x>=mod)x-=mod;}
#define maxn 100010
#define inf (1<<30)

int l,head[maxn],to[maxn*2],nxt[maxn*2],v[maxn*2];
void add(int x,int y,int z){
	nxt[++l]=head[x];head[x]=l;to[l]=y;v[l]=z;
}
int bfs[maxn*10],d[maxn],u[maxn];
int main(){
	int n;
	in(n);
	for(int i=0;i<n;i++){
		add(i,(i+1)%n,1);
		add(i,i*10%n,0);
	}
	memset(d,0x3f,sizeof(d));
	int l=1,r=2;
	bfs[l]=0;d[0]=0;
	while(l<r){
		int x=bfs[l++];u[x]=0;
		for(int i=head[x];i;i=nxt[i]){
			int c=to[i];
			if(d[x]+v[i]<d[c]){
				d[c]=d[x]+v[i];
				if(!u[c]){
					u[c]=1;
					bfs[r++]=c;
				}
			}
		}
	}
	int ans=inf;
	for(int i=1;i<n;i++){
		if((i+1)%n==0)ans=min(ans,d[i]+1);
		if(i*10%n==0)ans=min(ans,d[i]);
	}
	out(ans);
}

Measured memory_bytes: 7680
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<iomanip>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end()
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) // <a> must be sorted in advance

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}

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


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

    int H, W;
    string s[50];
    cin >> H >> W;
    REP(i, H) cin >> s[i];

    REP(i, H) {
        REP(j, W) {
            int cnt = 0;
            if(s[i][j] == '#') {
                cout << s[i][j];
                continue;
            }
            REP(d, 8) {
                int x = j + dx[d];
                int y = i + dy[d];
                if(x>=0&&x<W&&y>=0&&y<H && s[y][x]=='#') cnt++;
            }
            cout << cnt;
        }
        cout << endl;
    }
}


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

int main() {
    char s;
    cin >> s;
    if(s == 'A'){
        cout << 'T' <<endl;
    }
    else if (s =='T'){
        cout << 'A' <<endl;
    }
    else if (s == 'C'){
        cout << 'G' <<endl;
    }
    else if(s == 'G') {
        cout << 'C' <<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<string,int>a;
int x,y;
string s,ss,sss;
int main() {
    cin>>s>>ss;
    scanf("%d%d",&x,&y);
    cin>>sss;
    if(sss==s) x--;
    if(sss==ss) y--;
    printf("%d %d\n",x,y);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		while(in.hasNext())
		{
			int N=in.nextInt();
			int a[][]=new int[N][3];
			int b[]=new int[N];
			for(int i=0;i<N;i++)
			{
				for(int j=0;j<3;j++)
					a[i][j]=in.nextInt();
			}
			for(int i=0;i<3;i++)
			{
				for(int j=0;j<N;j++)
				{
					boolean judge=true;
					
					for(int k=0;k<N;k++)
					{
						if(j==k)
							continue;
						if(a[j][i]==a[k][i])
						{
							judge=false;
							break;
						}
					}
					if(judge)
					b[j]+=a[j][i];
				}
			}
			for(int i=0;i<N;i++)
				System.out.println(b[i]);
		}
	}
}

Measured memory_bytes: 20832
// not finished triangles triangles triangles triangles triangles triangles 

#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>

#define nl '\n'

using namespace std;

int a, b, t;

int main(){

    cin >> a >> b;

    t = a + b;

    while(t > 23){
        t = t - 24;
    }

    cout << t;


}

//g++ -std=c++14 comp.cpp -o b; ./b.exe
//g++ -std=c++14 comp.cpp && ./a.out

Measured memory_bytes: 256
#ifdef BUILT_LOCAL

#include "niklib.h"

#endif

#include <iostream>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <map>
#include <cmath>
#include <set>
#include <list>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
constexpr ll mod = 1000000007;

#define bs(n) (1ull<<(ull)(n))
#define rep(i, n) for(ll (i) = 0;(i) < (n);(i)++)

ll ds[400005];

ll bsa(ll n) {
    if (n == 0) return 1;
    if (ds[n] == 0) ds[n] = bsa(n - 1) * 2 % mod;
    return ds[n];
}

int main() {
    ll n, c[200000], r = 0;
    cin >> n;
    rep(i, n) cin >> c[i];
    sort(c, c + n, greater<>());
    rep(i, n) {
        r = (r + c[i] * (i + 2)) % mod;
    }
    r = (r * bsa((n - 1) * 2)) % mod;
    cout << r << endl;
}

Measured memory_bytes: 11136
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))}
const main=()=>{
  let [n,k]=tnn(2),balls=tnn(n),ans=0
  for(let i=0;i<n;i++){
    ans+=min(balls[i],abs(balls[i]-k))*2
  }
  to(ans)
}
main()

Measured memory_bytes: 9420
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;

#define M 1046527
long long T[M];

class Hash
{
	long long key;
	void getKey(char *p);
	int h1() { return key % M; }
	int h2() { return 1 + (key % (M - 1)); }
	int h(int i) { return (h1() + i*h2()) % M; }
public:
	void insert(char *str);
	bool find(char *str);
};

void Hash::getKey(char *p)
{
	key = 0;
	for (int i = (strlen(p) - 1); i >= 0; i--) {
		int x = p[i] % 9;
		key += x * pow(10, i);
	}
}

void Hash::insert(char *str)
{
	getKey(str);
	int i = 0;
	while (1) {
		int j = h(i);
		if (!T[j]) {
			T[j] = key;
			return;
		}
		else if (T[j] == key) return;
		else i++;
	}
}

bool Hash::find(char *str)
{
	getKey(str);
	int i = 0;
	while (1) {
		int j = h(i);
		if (T[j] == key) return 1;
		else if (!T[j]) return 0;
		else i++;
	}
	return 0;
}

int main()
{
	ios::sync_with_stdio(false);
	Hash H;
	int n;
	char order[10], word[15];
	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		scanf("%s %s", order, word);
		switch (order[0])
		{
		case 'i':
			H.insert(word); 
			break;
		case 'f':
			if (H.find(word)) printf("yes\n");
			else printf("no\n");
			break;
		default:
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 9420
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define INF 10000000
using namespace std;
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
signed main(){
    int n;
    cin >> n;
    rep(i,500){
        rep(j,500){
            if((4*i)+(7*j) == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String str = scan.nextLine();
    int n = Integer.parseInt(str);
    str = scan.nextLine();
    int count = (int)str.chars().filter(ch -> ch == 'R').count();
    long countLeft = (int)str.substring(0,count).chars().filter(ch -> ch == 'R').count();


    System.out.println(count-countLeft);
  }
}

Measured memory_bytes: 41588
import java.io.PrintWriter;
import java.util.Scanner;

public class Main
{
	static Scanner in;
	static PrintWriter out;
	static void solve()
	{
		int m = in.nextInt();
		int n = in.nextInt();
		int A = (m - 1) * (n - 1);
		out.print(A);
	}
	public static void main(String[] args)
	{
		in = new Scanner(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
		out.close();
		in.close();
	}
}

Measured memory_bytes: 21844
#include<iostream>
using namespace std;
typedef long long ll;
const int N = 1e5 + 7;
int main()
{
    int n;
    cin >> n;
    ll sum = 0;
    for(int i = 1; i <= n; i++)
    {
        if(i % 3 && i % 5)
            sum += (ll)i;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////

int main(){
    ll a,b;cin>>a>>b;
    string sa,sb;
    sa=to_string(a);
    sb=to_string(b);
    string ans="";
    if(a<b){
        rep(i,0,b-1){
            ans=ans+sa;
        }
        cout<<ans<<endl;
    }else{
        rep(i,0,a-1){
            ans=ans+sb;
        }
        cout<<ans<<endl;
    }
    
    return 0;
}


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

using namespace std;

int main(int argc, char **argv) {
    string S;
    int Q;

    cin >> S >> Q;

    bool reversed = false;

    for (int i = 1; i <= Q; i++) {
        int Ti;
        cin >> Ti;
        if (Ti == 1) {
            reversed ^= true;
        } else {
            int Fi;
            char Ci;
            cin >> Fi >> Ci;
            if (reversed)
                S.insert(Fi == 2 ? S.begin() : S.end(), Ci);
            else
                S.insert(Fi == 1 ? S.begin() : S.end(), Ci);
        }
    }

    if (reversed)
        S = string(S.rbegin(), S.rend());

    cout << S << endl;

    return 0;
}


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

class UnionFind{
public:
	vector<int> par;
	UnionFind(int n):par(n,-1){};//xが根ならpar[x]<0.-par[x]がその集合のサイズ.x=0~n-1.
	
	int root(int x){return par[x]<0?x:par[x]=root(par[x]);}//再帰.
	int size(int x){return -par[root(x)];}
	bool unite(int x,int y){
		x=root(x);
		y=root(y);
		if(x==y) return false;//do nothing.
		if(size(x)>size(y)) swap(x,y);
		par[y]+=par[x];
		par[x]=y;
		return true;//結合.
	}
};

int main(){
	int n,m;
	cin>>n>>m;
	
	vector<int> a,b;
	REP(i,m){
		int aa,bb;
		cin>>aa>>bb;
		a.push_back(--aa);
		b.push_back(--bb);
	}
	
	UnionFind island(n);
	vector<llong> ans(m);
	ans[m-1]=(llong)n*(n-1)/2;//m番時の橋がない状態.
	for(int i=m-1;i>=1;--i){
		if(island.root(a[i])!=island.root(b[i])){
			ans[i-1]=ans[i]-(llong)island.size(a[i])*island.size(b[i]);
			island.unite(a[i],b[i]);
		}else ans[i-1]=ans[i];
	}
	
	REP(i,m) cout<<ans[i]<<endl;
	return 0;
}//ABC120_d.復習.解説解答参考.

Measured memory_bytes: 3444
#include <iostream>
#include <utility>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;


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

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

    vector<int> dp(N);
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < N; i++) {
        int a1 = dp[i-1] + abs(h[i] - h[i-1]);
        int a2 = dp[i-2] + abs(h[i] - h[i-2]);
        dp[i] = min(a1, a2);
    }

    cout << dp[N-1] << endl;

    return 0;
}




Measured memory_bytes: 1024
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        a,b,c,d = LI()
        if a == 0:
            break
        for r in range(10000):
            if 1.0 * (a+d*r) / b >= c:
                rr.append(r)
                break

    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 9024
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define loop(i,n) rep(i,0,n)
using namespace std;
using ll = long long;
using pii=pair<int,int>;
int main(){
    int r,c,n;
    cin >> r >> c >> n;
    vector<pii> pq;
    loop(i,n){
        int x[2],y[2];
        cin >> x[0] >> y[0] >> x[1] >> y[1];
        bool flg[2];
        loop(j,2)flg[j]=(x[j]==0||x[j]==r||y[j]==0||y[j]==c);
        if(flg[0]&&flg[1]){
            loop(j,2){
                int tmp;
                if(x[j]==0)tmp=y[j];//[0,c]
                else if(x[j]==r)tmp=c+r+c-y[j];//[c+r,c+r+c]
                else if(y[j]==c)tmp=c+x[j];//(c,c+r)
                else if(y[j]==0)tmp=c+r+c+r-x[j];//(c+r+c,c+r+c+r)
                pq.push_back(pii(tmp,i));
            }
        }
    }
    sort(pq.begin(),pq.end());
    stack<int> qu;
    for(auto &v:pq){
        int i=v.second;
        if(!qu.empty()&&qu.top()==i)qu.pop();
        else qu.push(i);
    }
    cout << (qu.empty()?"YES":"NO") << endl;
    return 0;
}

Measured memory_bytes: 2420
n = int(input())

dList = sorted(list(map(int,input().split())))
dic = {}

for i in dList:
  
  if str(i) in dic.keys():
    dic[str(i)] += 1
  else:
    dic[str(i)] = 1
  if str(i+1) in dic.keys():
    dic[str(i+1)] += 1
  else:
    dic[str(i+1)] = 1
  
  if i-1 >= 0:
    if str(i-1) in dic.keys():
      dic[str(i-1)] += 1
    else:
      dic[str(i-1)] = 1
 
print(max(dic.values()))
  

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

dA=list()
for i in range(N-1):
    dA.append(A[i+1]-A[i])

# print(dA)
m=N-2
while m>0 and dA[m]<=0:
    m-=1
# print(m)

money=1000
stock=0
for i in range(m+1):
    if dA[i]>0:
        a = int(money / A[i])
        money -= (a*A[i])
        stock += a
    else:
        if dA[i]<0:
            money += (stock*A[i])
            stock = 0
    # print("i=",i," money=",money, " stock=", stock)

money += stock*A[m+1]
stock=0
# print("m+1=", m+1," A[m+1]=",A[m]," money=",money, " stock=", stock)

print(money)


Measured memory_bytes: 9068