akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main () {
  int P, Q, R;
  cin >> P >> Q >> R;
  
  if (min({P, Q, R}) == P) {
    cout << P + min(Q, R) << endl;
  }
  else if (min({P, Q, R}) == Q) {
    cout << Q + min(P, R) << endl;
  }
  else if (min({P, Q, R}) == R) {
    cout << R + min(P, Q) << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define endl '\n'
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
#define NIL -1
const int MOD = 1e9+7;
const int INF = 1 << 29;
const ll INFTY=1000000000000000000LL;
ll n,m;
ll a[MAX];
ll dp[MAX];
bool issafe[MAX];
int main(){
    memset(issafe,1,sizeof(issafe));
    cin>>n>>m;rep(i,m){
        cin>>a[i];
        issafe[a[i]]=false;
    }
    memset(dp,0,sizeof(dp));
    dp[0]=1;
    dp[1]=1;
    for(int i=2;i<=n;i++){
        if(issafe[i-1])dp[i]+=dp[i-1]%MOD;
        if(issafe[i-2])dp[i]+=dp[i-2]%MOD;
    }
    cout<<dp[n]%MOD<<endl;
}

Measured memory_bytes: 1920
//tumi cheye acho tai ami pothe hete jai
//hete hete bohudur bohudur jete chai
//ami_nafi

#include <bits/stdc++.h>
using namespace std;
#define pii pair <int, int>
#define vi vector <int>
#define pb push_back
typedef long long ll;
const int M = 1e6 + 20, MOD = 1e9 + 20;
int main () {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
   int r, c, n, ans;
   cin >> r >> c >> n;
   int x = max (r, c);
   if (n % x == 0) ans = n / x;
   else ans = n / x + 1;
   cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
ini = lambda : int(input())
inm = lambda : map(int,input().split())
inl = lambda : list(map(int,input().split()))
gcd = lambda x,y : gcd(y,x%y) if x%y else y
n = ini()
c = input()
rc = c.count('R')
lc = c[:rc].count('W')
print(lc)


Measured memory_bytes: 63316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAXN = 200100;

ll n, k, arr[MAXN], pref[MAXN];
ll ans; map<ll, ll> mp;

int main(){
	scanf("%lld %lld", &n, &k);
	for(ll i = 1; i <= n; i++) scanf("%lld", &arr[i]);
	for(ll i = 1; i <= n; i++) arr[i] = (arr[i] - 1) % k;
	for(ll i = 1; i <= n; i++) pref[i] = (pref[i - 1] + arr[i]) % k;
	ans = 0; mp[0] = 1;
	for(ll i = 1; i <= n; i++){
		if(i >= k) mp[pref[i - k]] = mp[pref[i - k]] - 1;
		ans = ans + mp[pref[i]];
		mp[pref[i]] = mp[pref[i]] + 1;
	}
	printf("%lld\n", ans);
	return 0;
}

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

using namespace std;

#define int long long
#define FR first
#define SC second
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)
#define each(a, b) for(auto& a : b)

typedef pair<int, int> P;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n; cin >> n;
  while(n--) {
    string s; cin >> s;
    int kind = 0;
    int sz = s.size();
    if(s[0] == '>' && s[1] == '\'' && s[sz-1] == '~' && s.size() > 5) kind = 1;
    else if(s[0] == '>' && s[1] == '^' && s[sz-1] == '~' && s[sz-2] == '~' && sz%2 == 0 && s.size() > 4) kind = 2;
    else kind = 3;
    if(kind == 1) {
      int cnt = 0, cmp = 0;
      for(int i = 2; i < sz-1 && kind != 3; i++) {
	if(s[i] != '=' && s[i] != '#') kind = 3;
	else {
	  if(s[i] == '=') cnt++;
	  else if(s[i] == '#' && !cmp) cmp = cnt, cnt = 0;
	  else kind = 3;
	}
      }
      if(cnt != cmp) kind = 3;
    } else if(kind == 2) {
      for(int i = 2; i < sz-2 && kind != 3; i+=2) {
	if(s.substr(i, 2) != "Q=") kind = 3;
      }
    }
    if(kind == 1) puts("A");
    else if(kind == 2) puts("B");
    else if(kind == 3) puts("NA");
  }
  
  return 0;
}

Measured memory_bytes: 3220
N = int(input())
path = [[0, 0, 0]]
for i in range(N):
    path.append(list(map(int, input().split())))

flag = False

for i in range(N):
    c = path[i]
    n = path[i+1]

    time_delta = n[0] - c[0]
    abs_distance = abs(n[1] - c[1]) + abs(n[2] - c[2])
    if abs_distance > time_delta:
        flag = True
        break
    else:
        if abs_distance%2 == 0 and time_delta%2 == 0:
            pass
        elif abs_distance%2 == 1 and time_delta%2 == 1:
            pass
        else:
            flag = True
            break

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

Measured memory_bytes: 27324
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main() {
  ll N, A, B; cin >> N >> A >> B;
  A--; B--; N--;
  ll r = INF;
  if((B - A) % 2 == 0) {
    chmin(r, (B - A) / 2);
  }
  chmin(r, B);
  chmin(r, N - A);
  ll rA = A + (B - A) / 2;
  if((B - A) % 2 == 1) {
    rA++;
  }
  ll NB = N - B;
  ll rB = NB + ((N - A) - NB) / 2;
  if(((N - A) - NB) % 2 == 1) {
    rB++;
  }
  chmin(r, rA);
  chmin(r, rB);
  cout << r << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#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 repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b;cin>>a>>b;
  if(a==12){
    cout<<b/2<<endl;
    return 0;
  }
  cout<<b/2*min(2LL,(a/6))<<endl;

  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
typedef long long ll;
using namespace std;
int memo[100001][4];
int A[100001], B[100001], C[100001];
int get_val(int prev, int n) {
	if(prev==1) {
			return A[n];
	} else if(prev==2) {
			return B[n];
	} else if(prev==3) {
			return C[n];
	}
	return 0;
}
 
int calc(int n, int prev) {
	if(n==1) {
		return get_val(prev, n);
	}
	
	if(memo[n][prev]!=-1) {
		return memo[n][prev];
	}
	
	int mx = INT_MIN;
	for (int i=1; i<=3; i++) {
		if(i!=prev) {
			int val = get_val(prev, n);
			mx = max(mx, calc(n-1, i) + val);
		}
	}
	
	memo[n][prev] = mx;
	
	return memo[n][prev];
}
 
int main() {
 	int n;
 	cin>>n;
 	
 	for (int i=1; i<=n; i++) {
 		cin>>A[i] >>B[i] >>C[i];
 		memo[i][1] = -1;
 		memo[i][2] = -1;
 		memo[i][3] = -1;
 	}
 	
 	//cout << calc(n+1, -1);
  int dp[100009][4];
  for (int i=0; i<100009; i++) {
  	for (int j=0; j<4; j++) {
  		dp[i][j] = INT_MIN;
  	}
  }
  dp[1][1] = get_val(1,1);
  dp[1][2] = get_val(2,1);
  dp[1][3] = get_val(3,1);
  
  for (int i=2; i<=n+1; i++) {
  	for (int j=1; j<=3; j++) {
  		for (int k=1; k<=3; k++) {
				if(j!=k) {
					dp[i][j] = max(dp[i][j], dp[i-1][k] + get_val(j,i));
				}
			}
  	}
  }
  
  cout << max(dp[n+1][1], max(dp[n+1][2], dp[n+1][3]));
   
	return 0;
}

Measured memory_bytes: 4480
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = 4;
        int[] a = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
        }
        sc.close();
        System.out.println(((a[0] - a[2]) * (a[1] - a[3])));
    }
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007; 
typedef long long ll;
typedef string str;
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; for(int cnt = 0; getline(stream,res,sp_word); cnt++)
#define scanln(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())
#define digit(x) ((int)log10((double)(x)) + 1)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define out(x) cout << (x) << endl;
#define outs(x) for(auto i : x) cout << i << " ";
ll gcd(ll a,ll b){while(b){ll tmp = a % b;a = b;b = tmp;}return a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}

int main(){
  ll n,k; cin >> n >> k;
  pair<ll,ll> ab[n];
  rep(i,n){
    cin >> ab[i].first >> ab[i].second;  
  }
  ll itr = 0;
  sort(ab, ab + n);

  for(auto i : ab){
    itr += i.second;
    if(itr >= k){
      cout << i.first;
      return 0;
    }
  }
}

Measured memory_bytes: 1792
// LONG LONG LOL

#include <bits/stdc++.h>

using namespace std;

int main(void)
{
    int n, W;
    cin >> n >> W;

    int  w[n], v[n];
    int  maxv = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> w[i] >> v[i];
        maxv += v[i];
    }

    long long dp[n + 1][maxv + 1] = {};

    for(int i = 0; i <= n; i++)
        for(int j = 0; j <= maxv; j++)
            dp[i][j] = 2000000000;


    dp[0][0] = 0;
    int maxtn = 0;
    for(int i = 1; i <= n; i++)
    {
        maxtn += v[i - 1];
        for(int j = 0; j <= maxtn; j++)
        {
            dp[i][j] = min(dp[i - 1][j], dp[i][j]);
            if(j >= v[i - 1])
            {
                dp[i][j] = min(dp[i - 1][j - v[i - 1]] + w[i - 1], dp[i][j]);
            }
        }
    }

    int ans = 0;

    for(int i = 0; i <= maxv; i++)
        if(dp[n][i] <= W)
            ans = max(ans, i);

    cout << ans << endl;

    /*for(int i = 0; i < n; i++)
        for(int j = 0; j <= maxv; j++)
            cout << i << " : " << j << " : " << dp[i][j] << endl;*/

    return 0;
}


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

int main() {
	long long n,m;
	cin>>n>>m;
	vector<pair<long long ,long long>>v(n);
	for(int i=0;i<n;i++)
	{
		cin>>v[i].first>>v[i].second;
	}
	sort(v.begin(),v.end());
	long long ans=0;
	for(int i=0;i<n;i++)
	{
		if(m>v[i].second)
		 {
		 	ans+=(v[i].second*v[i].first);
		 	//cout<<v[i].first<<endl;
		 	m-=v[i].second;
		 }
		 else
		 {
		 	//long cost = ceil (v[i].second/v[i].first);
		 	//cout<<1<<endl;
		 	//cout<<v[i].second<<m<<endl;
		    ans+=(long long)(v[i].first*m);
		    m=0;
		    break;
		 }
		 
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1792
// https://atcoder.jp/contests/abc096/tasks/abc096_d
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
struct cww {
    cww() {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
vector<int> P;
void prime(const int N) {
    for (int i = 2; i <= N; i++) {
        bool flag = true;
        for (int j = 2; j * j <= i; j++) {
            if (i % j == 0) {
                flag = false;
                break;
            }
        }
        if (flag) {
            P.emplace_back(i);
        }
    }
}
int main() {
    int n, cnt = 0;
    cin >> n;
    prime(55555);
    for (auto &x : P) {
        if (x % 5 == 1) {
            cout << x << " ";
            if (++cnt == n) {
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;

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

Measured memory_bytes: 3576
/***********************
*  Date: 2018.11.28    *
*  Problem:            *
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,m,q,co[100010],most[100010];
vector <int> g[100010];
vector <pair<int,pii> > qs;
bool vis[100010];

void dfs(int pos,int now,int all,int colo)
{
	if(all-now<=most[pos]) return;
	most[pos]=all-now;
	if(co[pos]==0) co[pos]=colo;
	if(now==all) return;
	rep(i,g[pos].size()) dfs(g[pos][i],now+1,all,colo);
}

int main()
{
	cin>>n>>m;
	memset(most,-1,sizeof(most));
	rep(i,m)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		g[x].pb(y);
		g[y].pb(x);
	}
	cin>>q;
	rep(i,q)
	{
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		qs.pb({x,{y,z}});
	}
	reverse(qs.begin(),qs.end());
	rep(i,q)
	{
		dfs(qs[i].fi,0,qs[i].se.fi,qs[i].se.se);
	}
	repn(i,n) printf("%d\n",co[i]);
	rt0;
}

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

int main() {
    ll n, x;
    cin >> n >> x;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

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

    ll sum = 0;
    ll ans = 0;

    rep(i, n) {
        sum += a[i];
        if(sum > x) {
            break;
        }
        if(sum <= x){
            ans++;
        }
    }
    if(sum<x){
        ans--;

    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <iostream>

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)      for(int i = 0; i < (n); ++i)
#define all(c)         begin(c), end(c)
#define rall(c)        rbegin(c), rend(c)
#define SZ(a)          ((ll) a.size())

typedef long long ll;
typedef unsigned long long ull;

int main(){
	int N;
	bool flag=false;
	scanf("%d",&N);
	vector<int> D(N+1);
	D[0]=0;
	rep(i,N) scanf("%d",&D[i+1]);
	sort(all(D));
	if(D[1]==0) flag=true;
	if(D[N]==12 and D[N-1] == 12) flag=true;
	rep(i,N-1){
		if(D[i]==D[i+1] and D[i+1]==D[i+2]) flag=true;
	}
	vector<int> E(D);
	int inv=0;
	int ans = -1;
	int tmp;
	if(flag) printf("0");
	else if(N>=12) printf("1");
	else{
		while(inv<pow(2,N)){
			rep(i,N){
				if((inv>>i)%2==1) {
					if(D[i+1]>0) E[i+1] = 24-D[i+1];
				}
				else{
					E[i+1] = D[i+1];
				}
			}
			tmp = 12;
			rep(i,N+1){
				FOR(j,i+1,N+1){
					tmp = min(tmp,min(abs(E[i]-E[j]),24-abs(E[i]-E[j])));
				}
			}
			ans = max(ans,tmp);
			inv+=1;
		}
		printf("%d",ans);
	}
  return 0;
}


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n,w;
	cin >> n >> w;
	// vector<vector<int>> dp(n+1,(vector<int>(w+1)));
	long int dp[n+1][w+1];
	vector<int> weights(n+1), values(n+1);
	// dp[i] maximum total value with weight w exactly
	for(int i=0; i<n; ++i) {
		cin >> weights[i] >> values[i];
	}
	//j=weight i=items
	for(int i=0; i<=n; ++i) {
		for(int j=0; j<=w; ++j) {
			if(i==0||j==0)
				dp[i][j]=0;
			else if(weights[i-1] > j)
				dp[i][j] = dp[i-1][j];
			else
				dp[i][j] = max(dp[i-1][j], dp[i-1][j-weights[i-1]]+values[i-1]);
		}
	}
	cout << dp[n][w] << "\n";
	return 0;
}


Measured memory_bytes: 79232
#include<bits/stdc++.h>
#define int long long
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 int mod=1e9+7;

void add(int &a,int b)
{
    a=(a+b)%mod;
}

void mul(int &a,int b)
{
    a=(a*b)%mod;
}

signed main()
{
    int N,M; cin>>N>>M;
    vector<int> a(N),b(M);
    for(int i=0;i<N;i++){
	cin>>a[i]; 
    }
    for(int i=0;i<M;i++){
	cin>>b[i];
    }
    sort(a.rbegin(),a.rend());
    sort(b.rbegin(),b.rend());
    a.push_back(0);
    b.push_back(0);

    int row=0,col=0;
    int ans=1;
    for(int num=N*M;num>=1;num--){
	if(a[row]==num and b[col]==num){
	    row++; col++;
	}else if(a[row]==num){
	    mul(ans,col);
	    row++;
	}else if(b[col]==num){
	    mul(ans,row);
	    col++;
	}else{
	    int cnt=row*col-(N*M-num);
	    if(cnt==0){
		ans=0; break;
	    }
	    mul(ans,cnt);
	}
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))
count = 0
for i in range(n-2):
    if p[i+1] > p[i] and p[i+1] < p[i+2]:
        count = count + 1
    elif p[i+1] < p[i] and p[i+1] > p[i+2]:
        count = count + 1
print(count)

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

int main() {
	double a,b,x;
	cin >> a >> b >> x;
	if (x <= a * a * b / 2) {
		double t = a*b*b/(2*x);
		double xp = 89;
		for (double i = 0; i < 90;i++) {
			if (tan(i * PI / 180) > t) {
				xp = i - 1;
				break;
			}
		}
		for (double i = 0.000001; i < 1; i += 0.000001) {
			if (tan(xp * PI / 180) > t) break;
			xp += 0.000001;
		}
		printf("%lf", xp);
		return 0;
	}
	else{
		double s = a * b - x / a;
		double tt = 2 * s / (a * a);
		double xp2 = 89;
		for (double i = 0; i < 90; i++) {
			if (tan(i*PI/180) > tt) {
				xp2 = i - 1;
				break;
			}
		}
		for (double i = 0.000001; i < 1; i += 0.000001) {
			if (tan(xp2*PI/180) > tt) break;
			xp2 += 0.000001;
		}
		
		printf("%lf", xp2);
		
		return 0;
	}
	

}





Measured memory_bytes: 512
#include<bits/stdc++.h>
#define faster_io ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mem(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define ll long long
#define pb push_back
#define pll pair<ll, ll>
using namespace std;
const ll N = 1e6 + 7, M = 1e5 + 7, mod = 998244353, inf = 1e9 + 7;
ll n, m, q, a, b, c, d, i, j, k, cnt = 1, ans;
ll ar[N];
vector < pll > vec;

int main()
{
    faster_io;
    cin >> n >> m;
    ll LCM = 1;
    for(i = 1; i <= n; i++)
    {
        cin >> ar[i];
        a = ar[i] = ar[i] / 2;
        if(LCM < inf)
            LCM = a * LCM / __gcd(a, LCM);
    }
    //cout << LCM << endl;
    if(LCM >= inf)
        cout << 0 << endl, exit(0);
    ll odd = 0, even = 0;
    for(i = 1; i <= n; i++)
    {
        a = LCM / ar[i];
        if(a % 2)
            odd = 1;
        else
            even = 1;
    }
    //cout << odd << ' ' << even << endl;
    if(odd && even)
        cout << 0 << endl, exit(0);
    if(even)
        LCM *= 2;
    cout << ((m / LCM) + 1) / 2 << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int  a=0,b=0,c=0,n=0,x=0,i=0,j=0,k=0;
    for(c=0;;c++){
        cin >> n >> x;
        if(n==0 && x==0)break;
        for(i=1;i<=n;i++){
            for(j=i+1;j<=n;j++){
                for(k=j+1;k<=n;k++){
                    a=i+j+k;
                    if(a==x)b++;

                }
            }
        }
        cout << b << endl;
        b=0;
    }

    /* for(i=0;i<d;i++){
        cout << arr[i];
         if(i<d-1)cout << endl;
     }*/
    //cout << endl;

return 0;

}

//1793081

Measured memory_bytes: 1160
#include<stdio.h>

int main() {
	int a, b;
	
	scanf("%d %d", &a, &b);

	if ((a - 2 * b) > 0) {
		printf("%d\n", a - 2 * b);
	}
	else {
		printf("0");
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a, n) \
    REP(i, n) { cout << (a[i]) << (i == n - 1 ? "\n" : " "); }
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) \
    SORT(a);     \
    reverse(a.begin(), a.end())
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll N;

int main()
{
    cin >> N;

    vector<vi> c = vector<vi>(10, vi(10));
    for (ll i = 1; i <= N; ++i)
    {
        string s = to_string(i);
        ++c[s[0] - '0'][s[s.size() - 1] - '0'];
    }
    ll ans = 0;
    for (ll i = 1; i <= 9; ++i)
    {
        for (ll j = 1; j <= 9; ++j)
        {
            ans += c[i][j] * c[j][i];
        }
    }

    OUT(ans);
}

Measured memory_bytes: 384
//A.cpp
#include <iostream>
#include <string>
#include <map>
using namespace std;

int main(){
  int N,A,B;
  cin >> N >> A >> B;
  int Ans = 0;
  for(int i = 1; i <= N; i++){
    int chk = 0;
    int x = i;
    while(x!=0){
      chk += x%10;
      x /= 10;
    }
    if(A<=chk&&chk<=B) Ans += i;
  }

  printf("%d\n",Ans);
  return 0;

}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;

int main(){
	string S;
	cin>>S;
	bool isC=false;
	for(int i=0;i<S.size();i++){
		if(i==0 && S[i]!='A'){
			cout<<"WA"<<endl;
			return 0;
		}
		
		if(2<=i && i <= S.size()-2){
			if(S[i]=='C'){
				if(!isC){
					isC=true;
				}else{
					cout<<"WA"<<endl;
					return 0;
				}
			} 
		}
		if(S[i]!='A' && S[i]!='C' && islower(S[i])==0){
			cout<<"WA"<<endl;
			return 0;
		}
	}
	if(isC){
		cout<<"AC"<<endl;
	}else{
		cout<<"WA"<<endl;
	}
	return 0;
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k;
    cin >> k;
    deque<P> deq;
    vector<int> visited(k, 0);

    deq.push_front(P(1, 1));
    while(!deq.empty()){
        P p = deq.front(); deq.pop_front();
        int cur = p.first, cnt = p.second;
        if(cur == 0){
            cout << cnt << endl;
            break;
        }

        visited[cur] = 1;
        int next = (cur + 1) % k;
        if(visited[next] == 0) deq.push_back(P(next, cnt+1));

        next = (cur * 10) % k;
        if(visited[next] == 0) deq.push_front(P(next, cnt));
    }
}


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

template <typename T>
struct flow_graph {
	
	struct edge {
		int from, to;
		T cap, f;
	};
	
	vector<edge> edges;
	vector<vector<int>> g;
	vector<bool> used;
	int n, st, fin;
	T flow;
	
	flow_graph(int n, int st, int fin) : n(n), st(st), fin(fin) {
		assert(0 <= st && st < n && 0 <= fin && fin < n && st != fin);
		g.resize(n);
		used.resize(n);
		flow = 0;
	}
	
	void clear_flow() {
		for (const edge &e : edges) {
			e.f = 0;
		}
		flow = 0;
	}
	
	void add(int from, int to, T cap = 1, T rev_cap = 0) {
		assert(0 <= from && from < n && 0 <= to && to < n);
		g[from].emplace_back(edges.size());
		edges.push_back({from, to, cap, 0});
		g[to].emplace_back(edges.size());
		edges.push_back({to, from, rev_cap, 0});
	}
	
	T dfs(int now, T f = numeric_limits<T>::max()) {
		if (now == fin) {
			return f;
		}
		used[now] = true;
		for (int id : g[now]) {
			edge &e = edges[id];
			if (!used[e.to] && 0 < e.cap - e.f) {
				T d = dfs(e.to, min(f, e.cap - e.f));
				if (0 < d) {
					e.f += d;
					edges[id ^ 1].f -= d;
					return d;
				}
			}
		}
		return 0;
	}
	
	T max_flow() {
		fill(used.begin(), used.end(), false);
		for (T f = dfs(st); 0 < f; fill(used.begin(), used.end(), false), f = dfs(st)) {
			flow += f;
		}
		return flow;
	}
};

int main() {
	int n, m;
	cin >> n >> m;
	flow_graph<int64_t> g(n, 0, n - 1);
	for (int i = 0; i < m; i++) {
		int from, to;
		int64_t cost;
		cin >> from >> to >> cost;
		g.add(from, to, cost);
	}
	cout << g.max_flow() << endl;
	return 0;
}

Measured memory_bytes: 3208
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
  static InputReader in;
  static PrintWriter out;

  static class Solution {
    void solve() throws IOException {
      while (true) {
        int H = in.nextInt();
        int W = in.nextInt();
        if (H == 0 && W == 0) break;
        
        for (int i = 0; i < H; i++) {
          if (i == 0 || i == H - 1) {            
            for (int j = 0; j < W; j++) {
              out.print("#");
            }
            out.print("\n");
          } else {
            out.print("#");
            for (int j = 1; j < W-1; j++) {
              out.print(".");
            }
            out.println("#");
          }
        }
        out.print("\n");
      }  
  }
}

  public static void main(String[] args) throws IOException {
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Solution solver = new Solution();
    solver.solve();
    out.close();
}

  static class InputReader {
    public BufferedReader br;
    public StringTokenizer st;

    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream));
    }

    public int nextInt() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Integer.parseInt(st.nextToken());
    }

    public long nextLong() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Long.parseLong(st.nextToken());
    }

    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return st.nextToken();
    }

    public double nextDouble() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Double.parseDouble(st.nextToken());
    }

  }

}

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

int main() {
    int K, ans;
    cin >> K;

    if(K%2==0){
        ans=(K/2)*(K/2);
    }else{
        ans=((K+1)/2)*((K-1)/2);
    }

    cout <<  ans << endl;  
}

Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	if ((tmp & ma0) ^ ma0) {
		int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
		tmp = tmp << dig & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += (72 - dig >> 3);
	}
	else {
		tmp = tmp & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += 8;
		if ((ct = *ci++) >= '0') {
			tmp = tmp * 10 + ct - '0';
			if (*ci++ == '0') {
				tmp = tmp * 10;
				ci++;
			}
		}
	}
	return tmp;
}

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


	int N = getint();
	int saidai = 0;
	ll kotae = 0;
	rep(i, N) {
		int a = getint();
		if (saidai < a) {
			saidai = a;
		}
		else {
			kotae += saidai - a;
		}
	}
	printf("%lld\n", kotae);

	Would you please return 0;
}

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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using uint=unsigned int;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

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

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

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

ll readLL(){
	ll i;
	scanf("%lld",&i);
	return i;
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

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

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

int main(){
	int n=read();
	string s=readString(),t=readString();
	REP(i,n+1){
		string p=s+t.substr(n-i,i);
		if(p.substr(0,n)==s&&p.substr(i,n)==t){
			cout<<p.size()<<endl;
			return 0;
		}
	}
}


Measured memory_bytes: 384
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut map: Vec<Vec<usize>> = vec![vec![]; n + 1];
    let mut org: Vec<(usize, usize)> = vec![];

    for _ in 0..m {
        let ni: usize = read();
        let y: usize = read();
        map[ni].push(y);
        org.push((ni, y));
    }

    for i in 0..map.len() {
        map[i].sort();
    }

    for i in 0..org.len() {
        let oi = org[i];
        let city = map[oi.0].binary_search(&oi.1).unwrap();
        let pn: String = format!("{:0>keta$}", oi.0, keta = 6 as usize);
        let cn: String = format!("{:0>keta$}", city + 1, keta = 6 as usize);
        println!("{}{}", pn, cn);
    }
}


Measured memory_bytes: 14588
#include "bits/stdc++.h"                                                         
                                                                                 
#define MOD 1000000007                                                           
#define rep(i, n) for(ll i=0; i < (n); i++)                                      
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)                                   
#define ALL(v) v.begin(),v.end()                                                 
#define rALL(v) v.rbegin(),v.rend()                                              
#define FOR(i, j, k) for(ll i=j;i<k;i++)                                         
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "                      
using namespace std;                                                        

/**************************************                                          
** A main function starts from here  **                                          
***************************************/                                         
int main(){                                                                      
  long long N, B1, B2;                                                          
  char s;                                                                     
  cin >> N >> B1 >> s >> B2;                                                     
  cout << setprecision(20)<<N*(B1*100+B2)/100;                                         
  return 0;                                                                    
}

Measured memory_bytes: 3632
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    X = int(readline())

    if X >= 30:
        print('Yes')
    else:
        print('No')

    return


if __name__ == '__main__':
    main()


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

#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)

#define SORT(c) sort((c).begin(),(c).end())
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

static const int N = 100;



int main(int argc, char const *argv[]) {
  cin.tie(0); ios::sync_with_stdio(false);
  int n;
  int p[N+1]; //M_i が p[i-1]行 p[i]列 となる
  int m[N+1][N+1]; //M_i ~ M_jまでをかけあわせたときの最小の掛け算の数
  std::cin >> n;
  REP1(i,n) std::cin >> p[i-1] >> p[i];
  REP1(i,n) m[i][i]=0;

  FOR(l, 2, n){
    REP1(i, n-l+1){
      int j = i+l-1;
      m[i][j] = INTINF;
      FOR(k, i, j-1){
        m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]);
      }
    }
  }

  std::cout << m[1][n] << '\n';

  return 0;
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define ull unsigned long long
#define FI(i,a,n) for(int i=a; i<=n; i++)
#define RFI(i,n,a) for(int i=n; i>=a; i--)
#define FLL(i,a,n) for(ll i=a; i<=n; i++)
#define RFLL(i,n,a) for(ll i=n; i>=a; i--)
#define vi vector<int>
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll>
#define pi pair<int, int>
#define GCD(a,b) __gcd(a,b)
#define MP make_pair
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define debug(x) cout << x << endl
#define MOD 1000000007
#define INF LLONG_MAX
#define PI 3.14159265359
using namespace std;

ll power(ll x, ll n, ll mod=MOD)
{
   ll ans = 1;
   x %= mod;
   while(n)
   {
     if(n&1) ans = (ans * x ) % mod;
     n >>= 1;
     x = (x*x)%mod;
   }
   return ans;
}

int main()
{
	fastio
  string s;
  cin >> s;
  int n = s.length();
  ll dp[n+1][13]={};
  if(s[n-1]!='?') dp[n-1][s[n-1]-'0']=1;
  else
  {
    for(int i=0; i<10; i++) dp[n-1][i]=1;
  }
  for(int i=n-2; i>=0; i--)
  {
    if(s[i]!='?')
    {
      int a = s[i]-'0';
      ll rem = ( a * power(10, n-i-1, 13) ) % 13;
      for(int j=0; j<13; j++) dp[i][(j + rem)%13] = dp[i+1][j];
      /* if(dp[i][rem]==0) dp[i][rem] = 1; */
    }
    else
    {
      for(int z=0; z<=9; z++)
      {
        int a = z;
        ll rem = ( a * power(10, n-i-1, 13) ) % 13;
        for(int j=0; j<13; j++) dp[i][(j + rem)%13] += dp[i+1][j], dp[i][(j+rem)%13]%=MOD;
        /* if(dp[i][rem]==0) dp[i][rem] = 1; */
      }
    }
  }
  cout << dp[0][5];





	return 0;
}





Measured memory_bytes: 10576
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int x = in();
    while (1){
        if (x % 111 == 0){
            cout << x << endl;
            return 0;
        }
        x++;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using namespace std;

int a, b;
char op;

int cal()
{

    cin>>a>>op>>b;

    if(op == '+')
    {
        cout<<a+b<<endl;
        cal();
    }
    else if(op == '-')
    {
        cout<<a-b<<endl;
        cal();
    }
    else if(op == '*')
    {
        cout<<a*b<<endl;
        cal();
    }
    else if(op == '/')
    {
        cout<<a/b<<endl;
        cal();
    }
    else if(op == '?')
        return 0;
}
    int main()
    {
        cal();

        return 0;
    }




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

using namespace std;

#define ll long long
#define M 1005000
#define ii pair<ll, ll>
#define iii pair<ll, ii>
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()



int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    char c;
    cin >> c;
    c++;
    cout << c;
    
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;
       
        static void SolveA()
        {
            int m = ReadAndParseInt();
            Console.WriteLine(48 - m);
        }


        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if( x == 2) { return true; }
            if( x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while( i * i <= x)
            {
                if( x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }

        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

int main() {
	lint K, S;
	cin >> K >> S;
	lint cnt = 0;
	for (lint i = 0; i <= K; i++) {
		for (lint j = 0; j <= K; j++) {
			lint Z = S - i - j;
			if (0 <= Z && Z <= K) {
				cnt++;
			}
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3584
s = gets.to_s

a=0
b=0
c=0

a = s.count('a')
b = s.count('b')
c = s.count('c')

if a==b && a==c then
	puts "YES"
	exit
end

if a==b && (a==c+1 || a==c-1) then
	puts "YES"
	exit
end

if a==c && (a==b+1 || a==b-1) then
	puts "YES"
	exit
end

if c==b && (b==a+1 || b==a-1) then
	puts "YES"
	exit
end

puts "NO"

	

Measured memory_bytes: 14388
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<30;
const ll LLINF = 1LL<<62;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};
ll ans = 0;
void rec(ll sm, ll old, int i,string S){
    if (i==S.size()){
        sm += old;
        //cout << sm << endl;
        ans += sm;
    }else{
        rec(sm+old,S[i]-'0',i+1,S);
        rec(sm,10*old+S[i]-'0',i+1,S);
    }

}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  rec(0,S[0]-'0',1,S);
  cout << ans << endl;

}


Measured memory_bytes: 256
#include <cstdio>

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1;i <= n;i++){
        int x = i;
        if(i % 3 == 0)
            printf(" %d",i);
        else{ 
            do{
                if(x % 10 == 3){
                    printf(" %d",i);
                    break;
                }
                x /= 10;
            }   
            while (x);
        }
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 2692
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define m_p			make_pair
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i =a, i>=b;i--)
#define sz(x)       (int)x.size()
#define F			first
#define S			second
#define debug(x)	for(int i=0;i<x;i++) cout<<"##########"<<endl
#define M			1000000007
#define ll			long long int
#define lMax		LLONG_MAX
#define pii 		pair<int ,int >
#define	all(a)		a.begin(), a.end()
#define vi 			vector<int> 
#define vii 		vector<pii>

// queue<int> , prefix_sum(a,a+n) , reverse(a,a+n) , priority_queue <int> max heap , priority_queue <int, vector<int>, greater<int> > min heap;
// == > != precedence gretaer then & , << precedence greater than <= == => , 
//int chk, cnt, fl, pos, in, src, tar, val, res. dummy;  fill (myvector.begin(),myvector.begin()+4,5), freq;

void solve()
{
	int h,w;
	cin>>h>>w;
	
	char arr[h][w];
	
	rep(i,0,h)
	{
		rep(j,0,w)
		{
			cin>>arr[i][j];
		}
	}
	int dp[h][w];
	dp[0][0]=1;
	rep(i,0,h)
	{
		rep(j,0,w)
		{
			if(i==0&&j==0) continue;
			if(arr[i][j]=='#') dp[i][j]=0;
			else 
			{
				if(i==0) dp[i][j]=dp[i][j-1];
				else if(j==0) dp[i][j]=dp[i-1][j];
				else dp[i][j]=(dp[i][j-1]+dp[i-1][j])%M;
			}
		}
	}
//	rep(i,0,h)
//	{
//		rep(j,0,w)
//		{
//			cout<<dp[i][j]<<" ";
//		}
//		cout<<endl;
//	}
	cout<<dp[h-1][w-1]<<endl;
}


signed main()
{
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		int t=1;
		while(t--)
		{
			solve();
		}
}

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

int main(){
    ll n,h,ans=0;
    cin >> n >> h;
    priority_queue<ll> aque,bque;
    for(int i = 0;i < n;i ++){
        ll a,b;
        cin >> a >> b;
        aque.push(a);
        bque.push(b);
    }
    while(!bque.empty()){
        if(bque.top()<aque.top()||h<=0) break;
        h -= bque.top();
        bque.pop();
        ans ++;
    }
    while(h>0){
        h -= aque.top();
        ans ++;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  int k = 0;
  int m = n;
  while(n > 0){
    k += n%10;
    n /= 10;
  }
  if(m % k == 0){
    puts("Yes");
  }
  else puts("No");
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

// #define EPS (1e-7)
// #define INF (1e9)
// #define PI (acos(-1))

// array<ll, 100000> P;
// array<ll, 100000> Y;

// int main() {
//   ll N, M;
//   cin >> N >> M;
//   // vector<int> P, Y;
//   for (ll i = 0; i < M; i++) {
//     ll p, y;
//     // cin >> p >> y;
//     // scanf("%d %d", &p, &y);
//     // P.push_back(p);
//     // Y.push_back(y);
//     scanf("%d %llx", &P[i], &Y[i]);
//   }

//   map<ll, vector<ll>> m;
//   for (ll i = 0; i < M; i++) {
//     m[P[i]].push_back(Y[i]);
//   }

//   for (map<ll, vector<ll>>::iterator it = m.begin(), end = m.end(); it !=
//   end;
//        ++it) {
//     sort(it->second.begin(), it->second.end());
//   }

//   for (ll i = 0; i < M; i++) {
//     vector<ll> v = m[P[i]];
//     vector<ll>::iterator itr;
//     itr = lower_bound(v.begin(), v.end(), Y[i]);
//     // cout << setfill('0') << setw(6) << right << P[i];
//     // cout << setfill('0') << setw(6) << right << itr - v.begin() + 1;
//     // cout << endl;
//     printf("%012lld\n", ll(P[i]) * 1000000 + ll(itr - v.begin() + 1));
//   }
//   return 0;
// }

#define rep(i, n) for (int i = 0; i < n; i++)
int N, M;
int P[100000], Y[100000];
vector<int> yd[100001];

int main() {
  scanf("%d%d", &N, &M);
  rep(i, M) scanf("%d%d", &P[i], &Y[i]), yd[P[i]].push_back(Y[i]);
  rep(i, N) sort(yd[i + 1].begin(), yd[i + 1].end());
  rep(i, M) printf("%012lld\n",
                   ll(P[i]) * 1000000 +
                       int(lower_bound(yd[P[i]].begin(), yd[P[i]].end(), Y[i]) -
                           yd[P[i]].begin()) +
                       1);
  return 0;
}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
#define INF 1 << 30
#define mod 1000000007
#define ll long long
#define pb push_back
#define pp pop_back
#define Loop(i,s,e) for(ll (i) = (s); (i) <= (e); ++(i))
#define desLoop(i,s,e) for(ll (i) = (s); (i) >= (e); --(i))
using namespace std;

typedef struct{int x,y;}point;

void Swap(ll*a,int x,int y){ll t=a[x];a[x]=a[y];a[y]=t;}
void Qsort(ll*n,int l,int r){if(l>=r)return;int i=l-1,j=r+1;ll m=n[(i+j)/2];
    while(1){while(n[++i]<m);while(n[--j]>m);if(i>=j)break;Swap(n,i,j);}
	Qsort(n,l,i-1);Qsort(n,j+1,r);}

ll min4(ll a,ll b,ll c,ll d){return min(min(a,b),min(c,d));}
ll max4(ll a,ll b,ll c,ll d){return max(max(a,b),max(c,d));}



int main()
{
	int len;
	while ( cin >> len ) {
		int change = 0;
		string a, b, c;
		cin >> a >> b >> c;
		
		while ( len-- ) {
			if ( a[len] == b[len] ) {
				if ( a[len] == c[len] ) continue;
				else change++ ;
			}
			else if ( a[len] == c[len] ) {
				change++ ;
			}
			else if ( b[len] == c[len] ) {
				change++ ;
			}
			else {
				change += 2;
			}
		}
		
		cout << change << '\n';
	}
	return 0;
}











Measured memory_bytes: 256