akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
 
#define MAX 100000
  
struct Cards {
    char pattern[2];
    int num;
    int order;
};
 
void exchange( struct Cards *pa, struct Cards *pb )
{
    struct Cards t;
     
    t=*pa;
    *pa=*pb;
    *pb=t;
 
    return;
}
 
int Partition( struct Cards A[], int p, int r )
{
    struct Cards x;
    int i,j;
 
    x=A[r];
    i=p-1;
    for( j=p; j<r; j++ ) {
        if( A[j].num <= x.num ) {
            i++;
            exchange( &A[i], &A[j] );
        }
 
    }
    exchange( &A[i+1], &A[r] );
 
    return i+1;
}
void QuickSort( struct Cards A[], int p, int r )
{
    int q;
     
    if( p < r ) {
        q=Partition( A, p, r );
        QuickSort( A, p, q-1 );
        QuickSort( A, q+1, r );
    }
    return;
}
int isStable( int n, struct Cards A[], struct Cards B[] )
{
    int i;
    int lo,mi,hi;
    int res=0;
    int s,e,t;
     
    res=1;
    for( i=0; i<n; i++ ) {
        lo=0;
        hi=n;
        while( lo <= hi ) {
            mi=(lo+hi)/2; 
            if( B[i].num == A[mi].num ) {
                if( A[mi].order ) {
                    if( A[ A[mi].order ].pattern[0] == B[i].pattern[0] ) {
                        e=s=mi;
                        while( B[i].num == A[s].num ) { s--; }
                        s++;
                        while( B[i].num == A[e].num ) { e++; }
                        e--;
                        t=A[mi].order+1;
                        while( s<=e ) {
                            A[s++].order=t;
                        }
                    } else {
                        res=0;
                    }
                } else {
                    e=s=mi;
                    while( B[i].num == A[s].num ) { s--; }
                    s++;
                    while( B[i].num == A[e].num ) { e++; }
                    e--;
                    t=A[mi].order+1;
                    while( s<=e ) {
                        A[s++].order=t;
                    }
                }
                break;
            } else if( B[i].num < A[mi].num ) {
                hi=mi-1;
            } else {
                lo=mi+1;         
            }
        }
        if( !res ) {
            break;
        }
    }
   
   return res;
}
 
int main( void ) 
{   
    int n,i;
    struct Cards A[MAX+1];
    struct Cards B[MAX+1];
         
    scanf( "%d", &n );
    for( i=0; i<n; i++ ) {
        scanf( "%s%d", A[i].pattern, &A[i].num );
        A[i].order=0;
        B[i]=A[i];
    }
    QuickSort( A, 0, n-1 );
     
    if( isStable( n, A, B ) ) {
        printf( "Stable\n" );
    } else {
        printf( "Not stable\n" );
    }
    for( i=0; i<n; i++ ) {
        printf( "%s %d\n", A[i].pattern, A[i].num );
    }
 
    return 0;
}

Measured memory_bytes: 2956
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld double
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define pll pair <ll,ll>
#define nl "\n"
ll n,wt;
ll w[102], v[102];
ll dp[2][100005]; 
int main()
{
	ios_base::sync_with_stdio(false);
	cin>>n>>wt;
	ll i,j;
	for(i=0;i<n;i++)
		cin>>w[i]>>v[i];
	for(i=0;i<2;i++)
		for(int j=0;j<100005;j++)
			dp[i][j]=-1;
	if(n==1)
	{
		cout<<v[0]<<nl;
		return 0;
	}
	for(i=0;i<=wt;i++)
		dp[1][i] = (i<w[n-1])?0:v[n-1];
	for(i=n-2;i>=0;i--)
	{
		for(j=wt;j>=0;j--)
		{
			dp[0][j] = dp[1][j];
			if(j >= w[i])
				dp[0][j] = max(dp[1][j-w[i]] + v[i], dp[0][j]);
			dp[1][j] = dp[0][j];
		}
	}
	cout<<dp[0][wt]<<nl;
	return 0;
}

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

int main()
{
  int n;
  cin >> n;
  bool lucky = false;
  while (n > 0)
  {
    if (n%10 == 7)
    {
      lucky = true;
      break;
    }
    n/=10;
  }
  if (lucky) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,x,y,z,ans;
  cin>>a>>b>>c>>x>>y;
  z=min(x,y);
  ans=min(a+b,2*c)*z;
  x-=z;
  y-=z;
  if(x>0) ans+=min(a,2*c)*x;
  else if(y>0) ans+=min(b,2*c)*y;
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#pragma GCC optimize ("O3")
	#define NDEBUG
#endif
// #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const array<int, 4> dx = {0, 1, 0, -1};
const array<int, 4> dy = {1, 0, -1, 0};


typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int n, k;
	while(cin >> n >> k) {
		string s;
		cin >> s;
		int cnt = 0;
		REP(i, SZ(s) - 1) {
			if(s[i] != s[i + 1]) cnt++;
		}
		DEBUG(cnt);
		cnt++;
		cout << min(SZ(s) - cnt + 2 * k, n - 1) << endl;
	}
	return 0;
}


Measured memory_bytes: 512
N,M = map(int,input().split())
shi_lst = [list(map(int,input().split())) for i in range(M)]
shi_sorted = sorted(shi_lst)
#print(shi_lst)

ans = {}
tmp = shi_sorted[0][0] #県の番号
count = 0#市の番号
for i in range(M):
  count += 1
  if tmp != shi_sorted[i][0]:
    count = 1
    tmp = shi_sorted[i][0]
  ans[str(shi_sorted[i][1])] = ("%06d"%tmp) + ("%06d"%count) 
#  ans.append( ("%06d"%tmp) + ("%06d"%count))
#  print( ("%06d"%tmp) + ("%06d"%count))

#print(ans)
for i in range(M):
  print(ans[str(shi_lst[i][1])])

Measured memory_bytes: 48612
//Just have Patience...
#include<bits/stdc++.h>
using namespace std;

#define tarzan ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long 

int rr[] = {0, 1, 1, 1, 0, -1, -1, -1};
int cc[] = {1, 1, 0, -1, -1, -1, 0, 1};

const int mod = 1e9 + 7;
const int N = 300050;

signed main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	tarzan;
	int test = 1;
	//cin >> test;
	while(test--) {
		string s;
		cin >> s;

		int ans = 0;
		for(int i = 0; i < s.size(); i++) {
			ans += (s[i] - '0');
		}
		
		cout << (ans % 9 ? "No" : "Yes") << '\n';
	}
	return 0;
}

Measured memory_bytes: 3736
/*input
5
0 0
1 1
5 5
6 6
7 7
2 2
3 3
4 4
8 8
9 9
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
pii a[maxn],b[maxn];
vector<pii> v;
set<pii> isa;
set<int> st;
int main()
{
	IOS;
	int n;
	cin>>n;
	REP(i,n) cin>>a[i].F>>a[i].S;
	REP(i,n) cin>>b[i].F>>b[i].S;

	REP(i,n) v.pb(a[i]);
	REP(i,n) v.pb(b[i]);
	sort(ALL(v));
	REP(i,n) isa.insert(a[i]);

	int ans=0;

	REP(i,2*n){
		pii cur=v[i];
		if(isa.count(cur)){
			st.insert(cur.S);
		}
		else{
			if(SZ(st)==0||cur.S<*st.begin());
			else{
				ans++;
				st.erase(prev(st.lower_bound(cur.S)));
			}
		}
	}
	cout<<ans<<'\n';
}



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

using namespace std;

int main()
{
  int i = 0;
  int tmp = 0;
  int ans = 0;
  int n;

  scanf("%d", &n);

  while((tmp += 2*i+1)<=n){
    ans = tmp;
    i++;
  }
  printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<functional>
#include<stack>
#include<utility>
#include<map>
#include<queue>

using namespace std;

int main() {
	long long n,fmin=100000000000;
	cin >> n;
	for (long long i = 1; i*i <= n; i++) {
		if (n%i == 0) {
			long long a = long(log10(i)) + 1, b = long(log10(n / i)) + 1;
			fmin = min(fmin, max(a,b));
		}
	}
	cout << fmin << endl;
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
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; }
using namespace std;

const int INF = 1e9;

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

    // 配るDP
    for (int i = 0; i < N; i++) {
        chmin(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
        chmin(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1024
print("Yes")
N, M = map(int, input().split())
path = [[] for _ in range(N)]
ind = [0 for _ in range(N)]
lis = [0] + [1 for _ in range(N-1)]
for i in range(M):
    A, B = map(int, input().split())
    path[A-1].append(B-1)
    path[B-1].append(A-1)
que = path[0]
for p in que:
    lis[p] = 0
for l in que:
    U = path[l]
    for m in U:
        if lis[m] ==1:
            ind[m] = l
            lis[m] = 0
            que.append(m)
    if lis == {}:
        break
for z in range(1,N):
    ind[z] += 1
    print(ind[z])

Measured memory_bytes: 37892
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef int ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
const ll UNDEF = -1;
const ll INF=1e9+5;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
#define fst first
#define snd second
const ll mn=1e5+2;
vector<ll> g[mn];
ll a[mn];
ll dp[mn];
ll f(ll x) {
	if (dp[x]!=-1) return dp[x];
	for (auto &y:g[x]) {
		if (a[y]<a[x]) {
			if (f(y)==0) {
				//printf("x:%d ans:1\n",x);
				return dp[x]=1;
			}
		}
	}
	//printf("x:%d ans:0\n",x);
	return dp[x]=0;
}
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	memset(dp,-1,sizeof dp);
	ll n; scanf("%d",&n);
	for (ll i=0;i<n;i++) {
		scanf("%d",&a[i]);
	}
	for (ll i=0;i<n-1;i++) {
		ll x,y; scanf("%d%d",&x,&y); --x; --y;
		g[x].PB(y); g[y].PB(x);
	}
	for (ll x=0;x<n;x++) {
		if (f(x)) printf("%d ",x+1);
	}
	printf("\n");
}



Measured memory_bytes: 3072
#Nはノード数、Mはエッジ数
n,m = map(int, input().split())

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

cnt=0

for x in ab:
  ls=list(range(n))
  for y in ab:
    if y !=x:
      for i in range(n):
        ls=[ls[y[0]-1] if ls[i]==ls[y[1]-1] else ls[i] for i in range(n)] #bの値を根っこ（低い方a）にする
  if len(set(ls)) !=1:
    cnt+=1

print(cnt)

Measured memory_bytes: 3064
x, y, z, k = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))
c = list(map(int, input().split(" ")))

ab = []
for i in range(x):
    for j in range(y):
        ab.append(a[i]+b[j])
ab.sort(reverse=True)
ab = ab[:min(x*y, k)]
abc = []
for i in range(len(ab)):
    for j in range(z):
        abc.append(ab[i]+c[j])
abc.sort(reverse=True)
for i in range(k):
    print(abc[i])

Measured memory_bytes: 159128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>

using namespace std;

void solve(int a, int b, int c) {
    int x = min(a, b);
    int nx = max(a, b);
    int y = min(c, nx);
    std::cout << x + y << std::endl;
}

int main() {
    struct timeval start,end;
    long long span;
    int a, b, c;

    gettimeofday(&start,NULL);

    std::cin >> a >> b >> c;
    solve(a, b, c);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=[0]*(n-1)
for i in range(n-1):
  b[i]=abs(a[i+1]-a[i])

bs=abs(a[0])
bl=abs(a[n-1])
sum=sum(b)+bs+bl

if 0<=a[0]<=a[1] or 0>=a[0]>=a[1]:
  print(sum)
else:
  print(sum-b[0]-bs+abs(a[1]))
  
for i in range(1,n-1):
  if a[i-1]<=a[i]<=a[i+1] or a[i-1]>=a[i]>=a[i+1]:
    print(sum)
  else:
    print(sum-b[i-1]-b[i]+abs(a[i+1]-a[i-1]))
    
if a[n-2]<=a[n-1]<=0 or a[n-2]>=a[n-1]>=0:
  print(sum)
  
else:
  print(sum-b[n-2]-bl+abs(a[n-2]))

Measured memory_bytes: 13920
#include<bits/stdc++.h>
using namespace std;
int main()
{
    cin.tie(NULL);
    ios::sync_with_stdio(false);    
    string s;
    cin>>s;
    for (int i = 0; i < s[i]; ++i)
    {
        s[i]='x';
    }
    cout<<s<<endl;
    return 0;
}


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

using namespace std;

#define MAX 1010
#define MAX_M 101

int dp[MAX_M][MAX_M][MAX];

int main()
{
    int LIMIT, N, M, X;
    string name;
    while (cin >> LIMIT >> N >> M >> X, LIMIT) {
        vector<int> c(N), s(N);
        for (int i = 0; i < N; i++) {
            cin >> name >> c[i] >> s[i];
        }
        int max_s[MAX];
        fill(max_s, max_s + MAX, -1);
        for (int i = 0; i < N; i++) {
            max_s[c[i]] = max(max_s[c[i]], s[i]);
            for (int j = i + 1; j < N; j++) {
                max_s[c[i] + c[j]] = max(max_s[c[i] + c[j]], s[i] + s[j]);
            }
        }
        for (int i = 0; i < LIMIT; i++) {
            max_s[i+1] = max(max_s[i+1], max_s[i]);
        }
        vector<int> sc(M), ss(M);
        for (int i = 0; i < M; i++) {
            cin >> name >> sc[i] >> ss[i];
        }
        for (int i = 0; i <= M; i++) {
            for (int j = 0; j <= M; j++) {
                for (int k = 0; k <= LIMIT; k++) {
                    dp[i][j][k] = -1;
                }
            }
            dp[i][0][0] = 0;
        }
        
        for (int i = 0; i < M; i++) {
            for (int j = 0; j <= M; j++) {
                for (int k = LIMIT; k >= 0; k--) {
                    if (dp[i][j][k] == -1) continue;
                    int nk = k + sc[i];
                    dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j][k]);
                    dp[i+1][j+1][nk] = max(dp[i+1][j+1][nk], dp[i][j][k] + ss[i]);
                }
            }
        }  
        
        int res = 0;
        for (int i = 0; i <= LIMIT; i++) {
            if (max_s[i] == -1) continue;
            for (int j = 0; j <= M; j++) {
                for (int k = X; k <= M; k++) {
                    if (dp[j][k][LIMIT-i] == -1) continue;
                    res = max(res, max_s[i] + dp[j][k][LIMIT-i]);                   
                }
            }
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 41456
#include <cstdio>
#include <cstring>
#include <cctype>
#include <algorithm>
inline int getint()
{
	int r = 0,s = 0;char c = getchar();for(;!isdigit(c);c = getchar()) s |= c == '-';
	for(;isdigit(c);c = getchar()) r = (((r << 2) + r) << 1) + (c ^ '0');return s ? -r : r;
}
const int N = 303;
int n,k,m;
inline void up(int &x,int y){if((x += y) >= m) x -= m;}
inline int add(int x,int y){return x + y >= m ? x + y - m : x + y;}
int f[N][N],c[N][N],s[N][N];
int main()
{
	n = getint(),k = getint(),m = getint();
	c[0][0] = 1;for(int i = 1;i <= n;i++){c[i][0] = 1;for(int j = 1;j <= i;j++) c[i][j] = add(c[i - 1][j - 1],c[i - 1][j]);}
	for(int i = 0;i <= k;i++) f[1][i] = 1,s[1][i] = k - i + 1;
	for(int x = k;~x;x--)
	{
		f[0][x] = 1;
		for(int i = 2;i <= n + 1;i++) for(int j = 1;j < i;j++) up(f[i][x],1LL * c[i - 2][j - 1] * (1LL * f[i - j][x] * s[j][x + 1] % m) % m);
		for(int i = 2;i <= n + 1;i++) s[i][x] = add(s[i][x + 1],f[i][x]);
	}
	printf("%d\n",f[n + 1][0]);
	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

typedef long long int ll;
typedef struct node
{
    int x,y;
    ll h;
}model;
model a[105];

ll MAX(ll a,ll b)
{
    if(a > b) return a;
    else return b;
}

int cmp(model m,model n)
{
    return m.h<n.h;
}

int main()
{
    int n;
    int i,j,k;
    int p;
    int cx,cy;
    ll H;

    scanf("%d",&n);
    for(i = 0;i < n;i++)
    {
        scanf("%d%d%lld",&a[i].x,&a[i].y,&a[i].h);
    }
    sort(a,a+n,cmp);
    p = 0;
    while(a[p].h == 0)
    {
        p++;
    }

    int flag;
    for(i = 0;i <= 100;i++)
    {
        for(j = 0;j <= 100;j++)
        {
            flag = -1;
            cx = i,cy = j;
            H = a[p].h+abs(cx-a[p].x)+abs(cy-a[p].y);

            for(k = 0;k < n;k++)
            {
                int temp = H-abs(cx-a[k].x)-abs(cy-a[k].y);
                if(temp < 0) temp = 0;
                if(a[k].h != temp)
                {
                    break;
                }
            }
            if(k == n)
            {
                flag = 1;
                break;
            }
        }
        if(flag == 1) break;
    }
    printf("%d %d %lld\n",cx,cy,H);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

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


ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}


int main(){
    int n;
    cin >> n;
    ll ans = 0;
    vector<ll>l(n);
    rep(i,n){
        cin >> l[i];
    }

    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            for(int k = j+1; k < n; k++){
                ll a = l[i] + l[j];
                ll b = l[k];
                vector<ll>num ={l[i],l[j],l[k]};
                sort(all(num));

                if(num[0]+num[1] > num[2]){
                    if((l[i] != l[j]) && (l[j] != l[k]) && (l[k] != l[i])){
                        ans ++;
                    }
                }  
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
#define mod 1000000007

int n, total;
vector<vector<bool>> b;
vector<vector<int>> dp;

int solve(int mask, int i)
{
	if(mask == total)
		return 1;
	if(i == n)
		return 0;
	if(dp[mask][i] == -1)
	{
		dp[mask][i] = 0;
		for(int j=0; j<n; j++)
		{	
			if(!(mask & (1<<j)) and b[i][j])
				dp[mask][i] = (dp[mask][i] + solve(mask | (1<<j), i+1))%mod;
		}
	}
	return dp[mask][i];
}

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

    cin>>n;
    vector<vector<int>> a(n, vector<int>(n));
    b = vector<vector<bool>>(n, vector<bool>(n));
    for(int i=0; i<n; i++)
    {
    	for(int j=0; j<n; j++)
    	{
    		cin>>a[i][j];
    		b[i][j] = (a[i][j] == 1);
    	}
    }

    total = (1<<n)-1;
    dp = vector<vector<int>>(total+1, vector<int>(n,-1));

    cout<<solve(0, 0)<<endl;
    return 0;
}

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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using namespace std;

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

    int n, m; cin >> n >> m;
    int ans[n];
    REPI(i, n) ans[i] = 0;
    REPI(i, m * 2){
        int x; cin >> x;
        ans[x - 1]++;
    }
    REPI(i, n) cout << ans[i] << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
#define REP(i, d, n) for(int i=(d); i<(n); i++)
typedef long long ll;
const int mod = 1e9 + 7;
int main() {

    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    ll ans = 0;
    if(c * 2 < a + b){
        if(x > y){     
            ans += 2 * c * y;
            ans += (x-y) * a;
        }
        else{
            ans += 2 * c * x;
            ans += (y-x) * b;
        }
        ans = min(ans, 2 * c * max(x, y));
    }
    else{
        ans += a * x + b * y;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i+100*j+50*k == x:
                count += 1
print(count)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX;
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;



int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	int n,i,a;
	cin>>n;
	map<int,int> m;
	int x[n];
	rep(i,n){
		cin>>a;
		m[a]++;
		m[a-1]++;
		m[a+1]++;
		x[i]=a;
	}
	map<int,int>::iterator it;
	int max=0,maxn,ans=0;
	for(it=m.begin();it!=m.end();it++){
		if(it->second>max){
			max=it->second;
			maxn=it->first;
		}
	}
//	cout<<maxn<<endl;
	for(i=0;i<n;i++){
		if(abs(x[i]-maxn)<=1){
			ans++;
//			cout<<it->first<<endl;
		}
	}
	cout<<ans<<endl;
	
	
	
//////////////////////////////////////////////////////
	return 0;
}


Measured memory_bytes: 5120
#include <vector>
#include <iostream>
#include <algorithm>
#include <limits>

using namespace std;
using graph = vector<vector<int>>;


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

    graph G(n, vector<int>(n, -1));
    for (int i = 0; i < n; ++i) {
        int u, k;
        cin >> u >> k;

        for (int j = 0; j < k; ++j) {
            int v, c;
            cin >> v >> c;
            G[u][v] = c;
        }
    }

    // Dijkstra's algorithm
    vector<int> d(n, -1);
    vector<bool> visited(n, false);

    d[0] = 0;
    visited[0] = true;
    while (1) {
        int u = -1;
        int v = -1;
        int minw = numeric_limits<int>::max();
        for (int i = 0; i < n; ++i) {
            if (!visited[i])
                continue;
            for (int j = 0; j < n; ++j) {
                if (G[i][j] < 0)
                    continue;
                int w = G[i][j] + d[i];
                if (!visited[j] && w < minw) {
                    u = i;
                    v = j;
                    minw = w;
                }
            }
        }
        if (v < 0) {
            break;
        }
        d[v] = minw;
        visited[v] = true;
    }

    for (int i = 0; i < n; ++i) {
        cout << i << " " << d[i] << endl;
    }

    return 0;
}

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

  int main() {
     long long N;
     cin >> N;
     long long A;
     A=N*(N+1)/2;
     for(int i=1; i<=N/3; i++){
        A-=3*i;
     }
     for(int i=1; i<=N/5; i++){
        A-=5*i;
     }
     for(int i=1; i<=N/15; i++){
        A+=15*i;
     }
     cout << A;



  }
      

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<vector>

template<class T> inline void chmax(T& a, T b){
	if(a < b){
		a = b;
		return;
	}
	return;
}

int main(){
	std::string s, t;
	std::cin >> s >> t;
	int sz = s.size();
	int tz = t.size();

	std::vector<std::vector<int>> dp(sz+1, std::vector<int>(tz+1));
	for(int i=0; i<sz; i++){
		for(int j=0; j<tz; j++){
			if(s[i] == t[j]){
				chmax(dp[i+1][j+1], dp[i][j] + 1);
			}
			chmax(dp[i+1][j+1], dp[i+1][j]);
			chmax(dp[i+1][j+1], dp[i][j+1]);
		}
	}

	int i = sz;
	int j = tz;
	std::string ans;
	while(i>0 && j>0){
		if(dp[i][j] == dp[i][j-1]){
			--j;
		}
		else if(dp[i][j] == dp[i-1][j]){
			--i;
		}
		else{
			ans = s[i-1] + ans;
			--i; --j;
		}
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 35584
## coding: UTF-8
mod = 998244353

N, S = map(int,input().split())
A = list(map(int,input().split()))

dp = []
for i in range(N+1):
    #dp.append([0]*3010)
    dp.append([0]*(S+1))
#print(dp)

dp[0][0] = 1
#print(dp)

#print('dpstart')
for i in range(N):
    for j in range(S+1):
        dp[i+1][j] += dp[i][j]
        dp[i+1][j] %= mod
        dp[i+1][j] += dp[i][j]
        dp[i+1][j] %= mod        
        if(j >= A[i]):
            dp[i+1][j] += dp[i][j-A[i]]
            dp[i+1][j] %= mod
    #print(dp)

print(dp[N][S])

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

using namespace std;

int main() {
    string w;
    cin >> w;
    char c[w.length()];
    for (int i = 0; i < w.length(); i++) {
        c[i] = w[i];
    }
    sort (c, c+w.length());
    bool beauty = true;
    int num = 1;
    char current = c[0];
    if (w.length() % 2 == 1) {
        beauty = false;
    }
    else {
        for (int i = 1; i < w.length(); i++) {
            if (c[i] == current) {
                num++;
            }
            else {
                if (num % 2 == 0) {
                    current = c[i];
                    num = 1;
                }
                else {
                    beauty = false;
                    break;
                }
            }
        }
    }

    if (beauty == true) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }

    return 0;
}



Measured memory_bytes: 3564
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned int uii;
const int maxn=100005;
int n,a,b;
ll A[maxn];
vector<int> tr[maxn];
ll dfs(int u,int fa) {
    if (tr[u].size()==1)
        return A[u];
    ll tot=0,x2=0,x1=0,mm,tm=0;
    for (uii i=0;i<tr[u].size();++i) {
        if (tr[u][i]==fa)
            continue;
        mm=dfs(tr[u][i],u);
        tm=max(tm,mm);
        tot+=mm;
    }
    x2=tot-A[u];
    x1=A[u]-x2;
    if (x1<0||x2<0||tm>A[u]||(x1>0&&fa==-1)) {
        puts("NO");
        exit(0);
    }
    return x1;
}
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;++i)
        scanf("%lld",&A[i]);
    if (n==1) {
        puts(A[1]?"NO":"YES");
        return 0;
    }
    for (int i=0;i<n-1;++i) {
        scanf("%d%d",&a,&b);
        tr[a].push_back(b);
        tr[b].push_back(a);
    }
    if (n==2)
        puts(A[1]==A[2]?"YES":"NO");
    else {
        for (int i=1;i<=n;++i)
            if (tr[i].size()>1) {
                dfs(i,-1);
                break;
            }
        puts("YES");
    }
    return 0;
}

Measured memory_bytes: 13184
#include<stdio.h>
int main(){
    long a,b,c;

    scanf("%ld %ld",&a,&b);
    c=a+b;

    if(c<=a-b){
            c=a-b;
    }
    if(c<=a*b){
         c=a*b;
    } 
    
    printf("%ld\n",c);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
#define RET(ans) {cout<<ans<<endl;return 0;} 

    // 二次元ベクターの基本
    /*
    vector<vector<int>> dp; // 宣言
    dp.resize(n); // 1次元めの要素数決定
    dp[i].push_back(int); // プッシュバック
    rep(i,n){
        sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート
    }
    */

    // 整数スキャン（複数）
    /*
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s; cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s; cin >> s;
        slist.push_back(s);
    }
    */

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

    rep(i,12){
        if(i==4){
            cout << ' ';
        }
        cout << s[i];
    }
    cout << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n;
vector <int> a;
map <int, int> mp;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    a.resize(n);
    for(auto &i : a){
        cin >> i;
        mp[i];
    }
    int x = 0;
    for(auto &i : mp) i.second = x++;
    for(auto &i : a) i = mp[i];
    int ans = 0;
    for(int i = 0 ; i < n ; i += 2){
        ans += a[i] % 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5376
function main()
    n, k = parse.(Int, split(readline()))
    a = parse.(Int, split(readline()))

    start = 1
    cur = 1
    times = 0
    hist = fill!(zeros(Int, n), -1)
    hist[1] = 0
    while true
        cur = a[cur]
        times += 1
        hist[cur] != -1 && break
        hist[cur] = times
        if times == k
            println(cur)
            return
        end
    end
    c = times - hist[cur]
    k = (k - hist[cur]) % c
    for i in 1:k
        cur = a[cur]
    end

    println(cur)


end

main()


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

int main(){
  int n; cin >> n;
  int h[n];
  for(int i = 0; i < n; i++) cin >> h[i];
  
  double sum=0;
  
  for(int j = 0; j < n; j++)
  {
    sum += (double)1 / (double)h[j];
  }
  
  sum = (double)1 / sum;
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int i, j;
    int num[10001] = {0};
    
    i = 0;
    while(1) {
        scanf("%d", &num[i]);
        if(num[i] == 0) break;
        i++;
    }
    
    for(j = 0; j < i; j++) {
        printf("Case %d: %d\n", j+1, num[j]);
    }
    return 0;
}


Measured memory_bytes: 1956
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1e17
#define ninf -1e17
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
ll n, w;
ll dp[105][100005];
ll wt[105];
ll val[105];
ll compute(int i, int cur)
{
    if(i==n)
    {
        if(cur==0) return 0;
        else return inf;
    }
    if(cur<0) return inf;
    if(dp[i][cur]!=-1) return dp[i][cur];
    ll ans = inf;
    ans = MIN2(ans, wt[i] + compute(i+1, cur-val[i]));
    ans = MIN2(ans, compute(i+1, cur));
    return dp[i][cur] = ans;
}
int main()
{
    she_told_me_dont_worry
    cin>>n>>w;
    ll i, j;
    FOR0(i, n)
    {
        cin>>wt[i]>>val[i];
    }
    memset(dp, -1, sizeof dp);
    ll ans = 0;
    FORD(i, 100000, 0)
    {
        if(compute(0, i) <= w)
        {
            ans = i;
            break;
        }
    }
    cout<<ans;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

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

int main()
{
    int x,y;  
    cin >> x;
    y=x/100;
    if( (1 <=y)&&(y<= 12)&&(1 <=(x-y*100))&&((x-y*100)<= 12) )
    {
    cout<< "AMBIGUOUS" << endl;    
}
    else if ( (1 <=y)&&(y<= 12) )
    {
        cout<< "MMYY" <<endl;
    }
    else if ((1 <=(x-y*100))&&((x-y*100)<= 12))
    {
        cout<< "YYMM" <<endl;
    }
    else {
        cout<< "NA" <<endl;
    }
}
    


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

string s1,s2,s3;
int a,b;
int main()
{
    ios::sync_with_stdio(false);
    cin>>s1>>s2;
    cin>>a>>b;
    cin>>s3;
    if(s3==s1)
        cout<<a-1<<" "<<b<<endl;
    else
        cout<<a<<" "<<b-1<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define F            first
#define S            second
#define pb(x)        push_back(x)
#define mp(a,b)      make_pair(a,b)
#define mt(a,b,c)    make_tuple(a,b,c)
#define sz           size()
#define all(A)       A.begin(), A.end()
#define mem(a, b)    memset(a, b, sizeof(a))   // all elements of A are b=0 or b=-1 else don't work
#define f0(i,b)      for(ll i=0;i<(b);i++)
#define f1(i,b)      for(ll i=1;i<=(b);i++)
#define f2(i,a,b)    for(ll i=(a);i<=(b);i++)
#define f3(i,b,a)    for(ll i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))

#define mod          10000007
#define PI           acos(-1.0)
#define MAX3(a,b,c)  max(a,max(b,c))

#define whilee(i,t)  while(i!=t)
#define  sl(a)       scanf("%lld",&a)
#define  pl(a)       printf("%lld\n",a)

//x = 1e18 means 10^18
//for(auto it =A.begin(); it!=A.end(); it++)
//sort(A.begin(),A.end()); //sort(A, +n, greater<int>());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//count(A.begin(), A.end(), X); //counts the occurrences of X
//distance(A.begin(),A.end());  //distance between first to last element
//accumulate(A.begin(), A.end(), 0); //add
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());
//swap(S[0], T[0]);

//scanf("%lld",&x);
//printf("%lld\n",x);
//printf("%I64d\n", a);
//while (scanf("%lld %lld", &a, &b) == 2)
//printf("Case %lld: %lld\n", t++, a);

// int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1};  // 4 Direction
// int dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1};  // 8 Direction
// int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1};  // Knight Direction
// int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1};  // Hexagonal Direction

//vector <ll> A;
//deque <ll> A;
//queue <ll> A;
//stack <ll> A;
//list <int> A;
//set <ll> A;
//map <ll,ll> A;
//unordered_map <ll, ll> A;
//pair <ll,ll> A ;
//tuple <ll, ll, ll> A;
//vector <pair <ll,ll>> A;
//bitset<32> bset1;
//bool ok = true;
//char ch;
string S, T, U;

ll i=0, j=0, k=0, a, b, c, d, e, f, g, h, l, m, n, o, p, q, r, s, t=1, u, v, w, x, y, z, maxx=INT_MIN, minn=INT_MAX, ans=0, sum=0, flag=0, cnt=0;

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

    cin>>n>>S;

    for(i=2; i<S.sz; i++)
    {
        if(S[i-2]=='A' && S[i-1]=='B' && S[i]=='C')
        {
            cnt++;
        }
    }

    cout<<cnt<<endl;
    return 0;
}



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

#define For(i, a, b) for (register int i = (a), i##_end = (b); i <= i##_end; ++ i)  
#define getc getchar_unlocked
#define inf (0x3f3f3f3f)
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define y1 igniubi

using namespace std;

inline int read() {
	int _ = 0, __ = getc(), ___ = 1; 
	for(; !isdigit(__); __ = getc()) if(__ == '-') ___ = -1;
	for(; isdigit(__); __ = getc()) _ = (_ << 3) + (_ << 1) + (__ ^ 48);
	return _ * ___;
}

const int N = 2e3 + 10;

int n, m, a[N][N], b[N][N], f[N][N], S[N], w[N], ans, top;

int main() {
	//freopen("speech.in", "r", stdin);
	//freopen("speech.out", "w", stdout);
	
	n = read(), m = read();
	For(i, 1, n) {
		char ss[N];
		scanf("%s", ss + 1);
		For(j, 1, m) {
			a[i][j] = ss[j] == '#';
			if(i > 1 && j > 1 && !((a[i][j] + a[i - 1][j] + a[i][j - 1] + a[i - 1][j - 1]) & 1)) 
				b[i - 1][j - 1] = 1;
		}
	}
	For(i, 1, n) For(j, 1, m) if(b[i][j]) f[i][j] = f[i][j - 1] + 1;

	For(j, 1, m) {
		top = 0;
		For(i, 1, n) {
			int kuan = 0;
			for(; top && f[S[top]][j] >= f[i][j]; -- top) {
				kuan += w[S[top]];
				ans = max(ans, min(n, kuan + 1) * min(m, f[S[top]][j] + 1));
			}
			w[i] = kuan + 1, S[++ top] = i;
		}
		int kuan = 0;
		for(; top; -- top) {
			kuan += w[S[top]];
			ans = max(ans, min(n, kuan + 1) * min(m, f[S[top]][j] + 1));
		}
	}

	printf("%d\n", max(max(n, m), ans));

	return 0;
}


Measured memory_bytes: 47488
h, w = map(int, input().split())
grid = []
ans = "Yes"
for i in range(h):
    grid.append(list(input()))
command = [(-1, 0), (1, 0), (0, -1), (0, 1)]

for x in range(h):
    for y in range(w):
        if grid[x][y] == "#":
            flag = "No"
            for m, n in command:
                try:
                    if grid[x + m][y + n] == "#":
                        flag = "Yes"
                except:
                    None
            if flag == "No":
                ans = flag
print(ans)


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll  a, b, n;
	cin >>a >>b >>n;
	
	ll x = n>=b-1? b-1: n;

	cout << ((a*x) /b  - a *(x/b)) <<"\n";
	return 0;
}


Measured memory_bytes: 3584
def solve(string):
    from itertools import combinations_with_replacement
    n, m, q, *abcd = map(int, string.split())
    ans = 0
    for v in combinations_with_replacement(range(1, m + 1), n):
        v = sorted(list(v))
        ans = max(
            ans,
            sum(d if v[b - 1] - v[a - 1] == c else 0 for a, b, c, d in zip(*[iter(abcd)] * 4)))
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 9076
//author Eterna King
#define Hello the_cruel_world!
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<utility>
#include<cmath>
#include<climits>
#include<deque>
#include<functional>
#include<numeric>
#define max(x,y) ((x) > (y) ? (x) : (y))
#define min(x,y) ((x) < (y) ? (x) : (y))
#define lowbit(x) ((x) & (-(x)))
#define FRIN freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\1.in", "r", stdin)
#define FROUT freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\1.out", "w", stdout)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define outd(x) printf("%d\n", x)
#define outld(x) printf("%lld\n", x)
#define memset0(arr) memset(arr, 0, sizeof(arr))
#define il inline
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int maxn = 2e5;
const int INF = 0x7fffffff;
const int mod = 1e9 + 7;
const double eps = 1e-7;
const double Pi = acos(-1.0);
il int read_int() {
	char c;
	int ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
il ll read_ll() {
	char c;
	ll ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
il ll quick_pow(ll base, ll index) {
	ll res = 1;
	while (index) {
		if (index & 1)res = res * base % mod;
		base = base * base % mod;
		index >>= 1;
	}
	return res;
}
ll r, d, x;
int main()
{
	cin >> r >> d >> x;
	for (int i = 1; i <= 10; ++i) {
		x = r * x - d;
		cout << x << endl;
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
H,W,K=map(int,(input().split()))
board=[list(input()) for _ in range(H)]
ans=0
for paint_H in range(2**H):
    for paint_W in range(2**W):
        cnt=0
        for i in range(H):
            for j in range(W):
                if(paint_H>>i)&1==0 and (paint_W>>j)&1==0:
                    if board[i][j]=="#":
                        cnt+=1
        if cnt==K:
            ans+=1
print(ans)

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

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

    for (int j = 0; j < k; j++)
    {
        vector<int> table(2 * n + 100,0);
        for (int i = 0; i < n; i++)
        {
            int start = (i - a[i]) * 2 - 1;
            if(start < 0)start = 0;
            int end = (i + a[i]) * 2 + 1;
            if(end >= 2 * n)end = 2 * n - 1;

            table[start]++;
            table[end]--;
        }

        for (int i = 1; i < 2 * n; i++)
        {
            table[i] += table[i - 1];
        }
        
        bool break_flag = true;
        for (int i = 0; i < 2 * n; i += 2)
        {
            a[i / 2] = table[i];
            if(a[i / 2] != n)break_flag = false;
        }
        if(break_flag)break;
    }

    for (int i = 0; i < n; i++)
    {
        cout << a[i] << " ";
    }
    cout << endl;
    
}


Measured memory_bytes: 5640
#include "bits/stdc++.h"
#define double long double
#define int long long
#define mii map<int,int>
#define low lower_bound
#define upp upper_bound
#define inf 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define sort(vec) sort(all(vec));
#define rever(vec) reverse(all(vec));
#define unsort(vec) sort(vec); rever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
int gcd(int a,int b) {
  if(b==0) return a;
  return gcd(b,a%b);
}
signed main() {
  int n;
  cin>>n;
  int a[n];
  int mi=inf;
  rep(i,n) cin>>a[i];
  rep(i,n-1) {
    mi=min(mi,gcd(a[i],a[i+1]));
  }
  cout<<mi<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define init(arr, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
const int inf = pow(10,9);
const int nil = -1;
int i, n, m, k, ans;
char c;
int a[100000];
int l[100000];
int r[100000];

int gcd(int p, int q) {
    if (p % q == 0) return p;
    return gcd(q, p%q);
}

int main() {
    scanf(" %d %d", &n, &m);
    bool preva = false;
    rep(0, n) {
        scanf(" %c", &c);
        if (c == 'C' && preva) {
            a[i] = a[i-1] + 1;
            preva = false;
        } else {
            a[i] = i!=0 ? a[i-1] : 0;
            preva = c == 'A';
        }
    }
    rep(0, m) {
        scanf(" %d %d", &l[i], &r[i]);
    }
    rep(0, m) {
        printf("%d\n", a[r[i]-1] - a[l[i]-1]);
    }
}

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

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

    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];

    sort(a.begin(), a.end());

    cout << a[0] << " " << a[1] << " " << a[2] << endl;

    return 0;
}


Measured memory_bytes: 3172
#include <iostream>
#include <climits>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <assert.h>
#include <vector>
#include <utility>
#include <string>
#include <bits/stdc++.h>
#include <fstream>
#include <chrono>
using namespace std;

typedef long long LL;

/*
        time complexty
auto start = chrono::steady_clock::now();
    ............

auto endd = chrono::steady_clock::now();
auto dif =   endd- start;
cout << chrono::duration<double, milli>(dif).count() <<"ms"<<endl;

*/


bool prime(LL n )
{
    if ( n < 4) return true;

    if ( (n%2 == 0) || (n%3 == 0) ) return false ;

    LL c= 5;

    while (c*c <= n  ){

        if ( (n%c==0) || (n%(c+2)==0)  ) return false ;
        c+=6;
    }
   return true;
}


LL gcd(LL one,LL two)
{
    while(two!=0)
    {
        LL t=two;
        two=one%two;
        one=t;
    }
    return one;
}

LL a , b , ans ;

int main(){

cin >>a >> b;
LL g = gcd(a , b);

for (LL i = 1 ;i*i <= g ; i++)

    if ((g%i == 0) && (g%i == 0)){
        ans+=prime(i);

        if ( (g/i) != i)  ans+= prime(g/i) ;

    }


cout <<ans<<endl;

return 0 ;
}


Measured memory_bytes: 3616