akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

const int MAXN = 10010;
const int MAXP = 10000000;
const u64 MOD = 998244353;
const f80 MI = f80(1)/MOD;
const ll INF = 10000000000000000LL;
const ll inf = 5000000000000LL;

int b[11] = {0,2,5,5,4,5,6,3,7,6};
int u[11];

int F[10010][5010];

void print(int i, int j)
{
	if (i == 0) return;
	for (int x = 9; x >= 1; -- x) if (u[x])
		if (i-b[x] >= 0 && F[i-b[x]][j-1])
		{
			printf("%d", x);
			print(i-b[x], j-1);
			break;
		}
}

int main()
{
	
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; ++ i)
	{
		int x;
		scanf("%d", &x);
		u[x] = 1;
	}
	F[0][0] = 1;
	for (int i = 0; i <= n; ++ i)
	{
		for (int j = 0; j <= 5000; ++ j)
		{
			if (!F[i][j]) continue;
			for (int x = 1; x <= 9; ++ x) if (u[x])
				F[i+b[x]][j+1] |= F[i][j];
		}
	}
	int ans = 0;
	for (int j = 5000; j >= 0; -- j)
		if (F[n][j])
		{
			ans = j;
			break;
		}
	print(n, ans);
	
	return 0;
}


Measured memory_bytes: 195200
N = int(input())
H = list(map(int,input().split()))

ans = 0
for i in range(N):
	a=0
	for j in range(i+1):
		if H[j] <= H[i]:
			a=a+1
		else:
			break
	if a == i+1:
		ans=ans+1

print(ans)
		

Measured memory_bytes: 2940
import sys
input = sys.stdin.readline
from collections import deque

n = int(input())
U = n**2
G = [[] for _ in range(U)]
parent = [0]*U
for i in range(n):
  A = list(map(lambda x:int(x)-1, input().split()))
  for j in range(n-2):
    a = A[j]
    b = A[j+1]
    G[min(i, a)*n+max(i, a)].append(min(i, b)*n+max(i, b))
    parent[min(i, b)*n+max(i, b)] += 1

que = deque([(i*n+j, 1) for i in range(n-1) for j in range(i+1, n) if not parent[i*n+j]])
ans = 1
cnt = 0
while que:
  v, t = que.pop()
  ans = max(ans, t)
  cnt += 1
  for nv in G[v]:
    parent[nv] -= 1
    if not parent[nv]:
      que.appendleft((nv, t+1))
if cnt == n*(n-1)//2:
  print(ans)
else:
  print(-1)

Measured memory_bytes: 165688
#include <bits/stdc++.h>
using namespace std;
#define modulo 100000
#define mod(mod_x) ((((long long)mod_x)+modulo)%modulo)
#define Inf 1000000000



int main(){
	int N,A,B;
	cin>>N>>A>>B;
	
	cout<<min(N*A,B)<<endl;
	
	
	
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
 
int main(){
    int n,m,x;
    cin>>n>>m>>x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    for (int i=0; i<n; i++){
        cin>>c[i];
        for (int j=0; j<m; j++){
            cin>>a[i][j];
        }
    }

    int cost=0;
    for (int i=0; i<n; i++){
        cost+=c[i];
    }
    //costを初期化
    bool check=false;

    //bit全探索開始
    for (int bit=0;bit< (1<<n) ;bit++){
        vector<int> s;
        for (int i=0; i<n ; i++){
            if(bit & (1<<i)){
                s.push_back(i);
            }
        }

        //sの中にはどの参考書を使うかのデータが入っている

        vector<int> rikaido(m,0);
        for (int i=0; i<s.size(); i++){
            for (int j=0; j<m; j++){
                rikaido[j]+=a[s[i]][j];
            }
        }
       
        //達成度チェック
        bool flg=true;
        for (int i=0; i<m; i++){
            if(rikaido[i]<x)flg=false;
        }
       
        if(flg){check=true;
        int icost=0;
        for (int i=0; i<s.size(); i++){
            icost+=c[s[i]];
        }
        
        cost=min(cost,icost);}
    }//ここまでbit全探索

    //kaitou

    if(check)cout<<cost<<endl;
    else cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 3636
///BISMILLAH'IR  RO'HMANIR  ROH'IM
///RIFAT SHARIAR SAKIL
///SOFTWARE ENGINEERING(SUST)

#include<stdio.h>
int main()
{
    int N,i,j;
    scanf("%d",&N);
    for(i=9;i>=1;i--)
    {
        if(N%i==0)
        {
            j=N/i;
            if(j<=9)
            {
                printf("Yes");
            }
            else printf("No");
            break;
        }
    }
    return 0;
}


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


int main()
{
	int i,count1,count2,ind1,ind2;
	float x[3],y[3],xp,yp;
	while( cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> xp >> yp ) {
		count1 = 0;
		count2 = 0;
		for( i = 0; i < 3; i++ ) {
			ind1 = i;
			ind2 = ( (i+1) % 3);
			if( ( ( xp -x[ind1] ) *( yp-y[ind2]) - (xp-x[ind2])*(yp-y[ind1]) ) < 0 ){
				count1 ++;
			}
			else if( ( ( xp -x[ind1] ) *( yp-y[ind2]) - (xp-x[ind2])*(yp-y[ind1]) ) > 0 ){
				count2 ++;
			}
		}
		if( count1 == 3 || count2 == 3 )
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}


	return 0;
}

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

using namespace std;
#define K 400001

int p[K], c[K], n, m;

int main() {
	scanf("%d%d", &n, &m);
	
	for (int i = 1; i <= n; i++) {
		p[i] = 0; c[i] = 1;	
	}
	
	p[1] = 1;
	
	for (int i = 1; i <= m; i++) {
		int u, v; scanf("%d%d", &u, &v);
		
		if (p[u]) p[v] = 1;
		c[u]--; c[v]++;
		
		if (c[u] == 0) p[u] = 0;	
	}
	
	int cnt = 0;
	
	for (int i = 1; i <= n; i++) cnt += p[i];
	
	cout << cnt << endl;
}

Measured memory_bytes: 1024
N = int(input())
A = [0]*N
X = []
Y = []
for i in range(N):
    A[i] = int(input())
    X.append([])
    Y.append([])
    for j in range(A[i]):
        x, y = map(int, input().split())
        X[i].append(x-1)
        Y[i].append(y)
ans = 0
for bit in range(1<<N):
    honest = 0
    ok = True
    for i in range(N):
        if bit&(1<<i):
            honest += 1
            for j in range(A[i]):
                if Y[i][j] == 0:
                    if bit&(1<<X[i][j]):
                        ok = False
                        break
                else:
                    if not bit&(1<<X[i][j]):
                        ok = False
                        break
            if not ok:
                break
    if ok:
        ans = max(ans, honest)
print(ans)

Measured memory_bytes: 3064
_ = input()
a = [int(i) for i in input().split()]
mod = 10**9 + 7
c = [0, 0, 0]
cnt = 1
for ai in a:
    if ai not in c:
        print(0)
        break
    cnt = cnt * c.count(ai) % mod
    c[c.index(ai)] += 1
else:
	print(cnt)

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

int main() {
  int alphabet[26] = {};
  string w;
  cin >> w;

  for (int i = 0; i < w.size(); i++) {
    alphabet[w[i] - 'a']++;
  }

  bool ans = false;
  for (int i = 0; i < 26; i++) {
    if (alphabet[i] % 2 == 1) {
      ans = true;
      break;
    }
  }

  if (ans) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<complex>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

Int n, m, k;
Int dp[4200][2200];
Int dp_sum[4200][2200];

int main(){
    cin >> n >> m >> k;
    int l = (n + m - 1) / (k - 1);
    dp[0][0] = 1;
    for(int i = 1;i <= l;i++){
        for(int j = 0;j <= n;j++){
            dp_sum[i-1][j] = dp[i-1][j];
            if(j)(dp_sum[i-1][j] += dp_sum[i-1][j-1]) %= MOD;
        }
        for(int j = 0;j <= n;j++){
            dp[i][j] += dp_sum[i-1][j];
            if(j-k>=0)dp[i][j] -= dp_sum[i-1][j-k];
            dp[i][j] %= MOD;
        }
    }
    Int ans = 0;
    for(int i = l;i >= 1;i--){
        int sum = n - (k-1) * (l-i);
        if(sum <= 0)break;
        ans += dp[i][sum];
        ans %= MOD;
    }
    if(ans < 0)ans += MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 139520
x1, y1, x2, y2 = map(int, input().split())
x3 = x2+(y1-y2)
y3 = y2-(x1-x2)
x4 = x1+(y1-y2)
y4 = y1-(x1-x2)
print(x3, y3, x4, y4)


Measured memory_bytes: 9148
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
vector<int> g[100005];
queue<int> que;
int from[100005]={0};
int main(){
	int i,f,t,n,m;
	scanf("%d%d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d%d",&f,&t);
		g[f].emplace_back(t);
		g[t].emplace_back(f);
	}
	from[1]=1;
	que.push(1);
	while(que.size()){
		int v=que.front();
		que.pop();
		for(auto x:g[v]){
			if(!from[x]){
				from[x]=v;
				que.push(x);
			}
		}
	}
	for(i=1;i<=n;i++)
		if(!from[i]){
			puts("No");
			return 0;
		}
	puts("Yes");
	for(i=2;i<=n;i++)
		printf("%d\n",from[i]);
}


Measured memory_bytes: 10052
s = input()
phase = 'Odd'
ptn10 = 0
ptn01 = 0
for i in s:
  if phase == 'Odd':
    if i == '1':
      ptn01 += 1
    else:
      ptn10 += 1
    phase = 'Even'
  else:
    if i == '0':
      ptn01 += 1
    else:
      ptn10 += 1
    phase = 'Odd'
print(min(ptn10, ptn01))

Measured memory_bytes: 9100
def main():
    N = int(input())
    AB = []
    for _ in range(N):
        temp = list(map(int, input().split()))
        AB.append((temp[0], temp[1]))

    sorted_AB = sorted(AB, key=lambda x: x[1])

    total_time = 0
    flag = True
    for x in sorted_AB:
        total_time += x[0]
        if total_time > x[1]:
            flag = False
            break

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

if __name__ == '__main__':
    main()

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

int main(){
  while(true){
    int H, W;
    cin >> H >> W;
    if(H == 0 && W == 0) break;
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        cout << '#';
      }
      cout << endl;
    }
    cout << endl;
  }
}


Measured memory_bytes: 3092
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

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

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
    if (ib == ie) {
        ib = ibuf;
        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
    }
    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

const size_t N = 1e6 + 5;
const int MOD = 1e9 + 7;
const int INV3 = (MOD + 1) / 3;

int inv[N];

int main() {
    int n = read();
    inv[0] = inv[1] = 1;
    for (int i = 2; i <= n; ++i) {
        inv[i] = MOD - (LL) (MOD / i) * inv[MOD % i] % MOD;
    }
    int ans = 0;
    int mul = inv[n];
    for (int i = 0; i < n; ++i) {
        mul = (LL) mul * INV3 % MOD;
        ans = (ans + (LL) mul * inv[n - i]) % MOD;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 4352
MOD = 1_000_000_007

def comb(n, k)
  return comb(n, n - k) if k > n - k
  return 1 if k == 0
  c = 1
  (1..k).each do |i|
    c *= (n - i + 1)
    c /= i
  end
  c % MOD
end

loop do
  n, d, x = gets.split.map(&:to_i)
  break if n == 0
  if d * (x - 1) < n
    puts 0
    next
  end
  in_ex = 0
  (0..n/x).each do |k|
    in_ex += (-1) ** k * comb(d, k) * comb(n - x * k + d - 1, d - 1)
  end
  p in_ex % MOD
end


Measured memory_bytes: 37000
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb; 
typedef long long ll;  
typedef double db;                         
 
 
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, N = 3e2 + 48, mod = 1e9 + 7;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


int n, m, v, u, w, l, Q;
vpii g[N]; 
pii d[N][N];
set < pair < pii, int > > q;

main () {
//	file("");
	cin >> n >> m >> l;
	while (m--) {
		cin >> v >> u >> w;
		if (w > l)
			continue;
		g[v].pb(mp(u, w));		 	
		g[u].pb(mp(v, w));
	}

	forn (i, 1, n) {
		forn (j, 1, n)
			d[i][j] = mp(inf, inf);

		d[i][i] = mp(0, -l);
		q.insert(mp(d[i][i], i));

		while (sz(q)) {
			int v = q.begin()->s;
			q.erase(q.begin());

			for (auto x : g[v]) {
				int to = x.f, w = x.s;
				pii cost = d[i][v];
				cost.s += w;
				if (cost.s > 0) {
					cost.s = -l + w;
					++cost.f;
				}	

				if (d[i][to] > cost) {
					q.erase(mp(d[i][to], to));
					d[i][to] = cost;
					q.insert(mp(d[i][to], to));
				}
			}
		}		
	}	

	cin >> Q;
	while (Q--) {
		cin >> v >> u;
		if (d[v][u].f == inf)
			cout << -1 << endl;
		else
			cout << d[v][u].f << endl;				
	}
}


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

int main() {
	char szBuf[6];
	cin >> szBuf;
	if (szBuf[2] == szBuf[3] && szBuf[4] == szBuf[5])cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}



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

int main() {
  int a, b;
  cin >> a >> b;
  cout << max(a+b, max(a - b, a * b)) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

int main() {
	int N;
    cin >> N;
    ll C;
    cin >> C;
    vector<P> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i).first >> vec.at(i).second;
    }
    ll cnt = 0;
    vector<P> rMax(N + 1);
    for(int i = 0;i < N;i++) {
        cnt += vec.at(i).second;
        if(rMax.at(i).first < cnt - vec.at(i).first) {
            rMax.at(i + 1) = P(cnt - vec.at(i).first,vec.at(i).first);
        }
        else {
            rMax.at(i + 1) = rMax.at(i);
        }
    }
    cnt = 0;
    vector<P> lMax(N + 1);
    for(int i = N - 1;i >= 0;i--) {
        cnt += vec.at(i).second;
        if(lMax.at(i + 1).first < cnt - (C - vec.at(i).first)) {
            lMax.at(i) = P(cnt - (C - vec.at(i).first),C - vec.at(i).first); 
        }
        else {
            lMax.at(i) = lMax.at(i + 1);
        }
    }
    ll ret = 0;
    for(int i = 0;i < N + 1;i++) {
        ret = max(ret,rMax.at(i).first + lMax.at(i).first - min(rMax.at(i).second,lMax.at(i).second));
    }
    cout << ret << endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <cassert>

using namespace std;

const int DICE_SIZE = 6;
int const CmdCount = 6;
int const RotateLen = 4;

//?????????
//??±?\????????????¢???????????¨?????§?????????
class dice {
  //?????????,?????¢,??±??¢,?\???¢,?????¢,?????¢?????°???
  int values[DICE_SIZE];
public:
  dice ();
  virtual ~dice ();
  int &operator[](int i){
    assert(0 <= i && i < DICE_SIZE);
    return values[i];
  };
  void docmd(string str);
  void docmd(char c);
  void setTopAndFront(int top,int front);
  void input(void);
  int right(void){return values[2];};
  int top(void){return values[0];};
  int front(void){return values[1];};
private:

  int indexs[CmdCount][RotateLen];
  char *cmdChar;
  string *toTopCmd;
  string *toFrontCmd;
  void move_forward(int *indexs);
  int find_value(int num);
};
void dice::setTopAndFront(int top, int front){
  int idxTop = find_value(top);
  docmd(toTopCmd[idxTop]);
  int idxFront = find_value(front);
  docmd(toFrontCmd[idxFront]);
}
int dice::find_value(int num){
  for(int i = 0; i < DICE_SIZE; i++){
    if(values[i] == num){
      return i;
    }
  }
  assert(false);
}
dice::dice(){
  int westindex[RotateLen] = {1, 3, 6, 4};
  int northindex[RotateLen] = {1, 2, 6, 5};
  int leftindex[RotateLen] = {4, 2, 3, 5};
  cmdChar = new char[CmdCount]{'W', 'E', 'N', 'S','L','R'};
  for(int i = 0; i < RotateLen; i++){
    indexs[0][i] = westindex[i] - 1;//W
    indexs[1][i] = westindex[RotateLen - i - 1] - 1;//E
    indexs[2][i] = northindex[i] - 1;//N
    indexs[3][i] = northindex[RotateLen - i - 1] - 1;//S
    indexs[4][i] = leftindex[i] - 1;//L
    indexs[5][i] = leftindex[RotateLen - i - 1] - 1;//R
  }
  toTopCmd = new string[DICE_SIZE]{"","N","W","E","S","NN"};
  toFrontCmd = new string[DICE_SIZE]{"S","","L","R","LL","N"};
}
dice::~dice(){
  delete [] cmdChar;
  delete [] toTopCmd;
  delete [] toFrontCmd;
}

void dice::docmd(string str){
  for(int i = 0; i < str.length(); i++){
  //  cout << "docmd(str[i])" << str[i] << endl;
    docmd(str[i]);
  }
}

void dice::docmd(char c){
  for(int i = 0; i < CmdCount; i++){
    if (c == cmdChar[i]){
    //  cout << cmdChar[i] << endl;
      move_forward(indexs[i]);
      return;
    }
  }
  assert(false);//????????¨???????????????
}
void dice::move_forward(int *indexs){
  int temp = values[indexs[0]];
  values[indexs[0]] = values[indexs[1]];
  values[indexs[1]] = values[indexs[2]];
  values[indexs[2]] = values[indexs[3]];
  values[indexs[3]] = temp;
}
void dice::input(void){
  for(int i=0; i < DICE_SIZE; i++){
    int n;
    cin >> n;
    values[i] = n;
  }
}
int main(int argc, char const *argv[]) {
  dice d1,d2;
  d1.input();
  d2.input();
  d2.setTopAndFront(d1.top(),d1.front());
  int isEqual = true;
  for(int i = 0; i < DICE_SIZE; i++){
    if (d1[i] != d2[i]){
      isEqual = false;
      break;
    }
  }
  if (isEqual){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3224
# -*- coding: utf-8 -*-
"""
Created on Sun Nov  4 18:54:20 2018
ABC113C
@author: maezawa
"""

n, m = list(map(int, input().split()))
p = [0]
y = [0]
for i in range(m):
    pi, yi = list(map(int, input().split()))
    p.append(pi)
    y.append(yi)

#print(p)
#print(y)
    
cityn = ['']*m

ps = [[] for _ in range(n+1)]
for i in range(1,m+1):
    ps[p[i]].append(i)
    
for j in range(1,n+1):
    ps[j].sort(key = lambda x: y[x])
    for i, k in enumerate(ps[j]):
        left = '000000'+ str(j)
        right = '000000' + str(i+1)
        cityn[k-1] = left[len(left)-6:] + right[len(right)-6:]

for i in range(m):
    print(cityn[i])
    

Measured memory_bytes: 34332
fun main(arr:Array<String>) {
    val n = readLine()!!.toInt()
    val words = (1..n).map { readLine()!!.toList().sorted().joinToString("") }.sorted()
    var prev = words[0]
    var start = 0
    var ans = 0L
    for(i in (1 until n)) {
        if(prev == words[i]) {
            continue
        }
        val cnt = i - start.toLong()
        if(cnt >= 2) {
            ans += (cnt*(cnt-1)/2)
        }
        start = i
        prev = words[i]
    }
    val cnt = n - start.toLong()
    if(cnt >= 2) {
        ans += (cnt*(cnt-1)/2)
    }
    println(ans)
}



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

#define rep(i,n) for( (i)=0;(i)<(n);++(i) )
#define repr(i,n) for( (i)=(n);(i)>0;==(i) )
#define FOR(i,j,n) for( (i)=(j);(i)<(n);++(i) )
#define forr(i,j,n) for( (i)=(j);(i)>(n);--(i) )
#define debg(a) cout<<(a)<<endl;
#define INF 9999999
#define int long long 
#define str string
#define elif else if


int i,j,k;
int dx,dy;
int a,b,c,x,y,z,n,m,cnt=0,ans=0;
str s,t;


signed main(){ 
  str a,b,c;
  cin>>a>>b>>c;
  char next=a[0]; 
  x=0;y=0;z=0;
  for(;;){
    if(next=='a'){
      next=a[x]; x++; }
    elif(next=='b'){
      next=b[y]; y++; }
    elif(next=='c'){
      next=c[z]; z++; }

    if(x>a.length()){ debg('A'); return 0; }
    if(y>b.length()){ debg('B'); return 0; }
    if(z>c.length()){ debg('C'); return 0; }
  }


  return 0;
}


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

const int INF = 1e9;
const int MAX_N = 51;
const int MAX_M = 51;

char maze[MAX_N][MAX_M+1];
int n, m;
int sx, sy;
int gx, gy;
int d[MAX_N][MAX_M];
int dx[4] = {0, -1, 0, 1};
int dy[4] = {1, 0, -1, 0};

int main() {
  cin>>n>>m;
  sx = 0, sy = 0;
  gx = n-1, gy = m-1;
  rep(i, n) {
    rep(j, m) {
      cin >> maze[i][j];
    }
  }
  queue<P> que;
  int cnt = 0;
  rep(i, n) {
    rep(j, m) {
      if (maze[i][j]=='#') cnt++;
      d[i][j] = INF;
    }
  }
  que.push(P(sx, sy));
  d[sx][sy] = 0;

  int sharp = 0;

  while (que.size()) {
    P p = que.front();
    if (p.first==gx&&p.second==gy) break;
    que.pop();
    rep(i, 4) {
      int nx = p.first + dx[i];
      int ny = p.second + dy[i];
      if (nx < 0 || n <= nx) continue;
      if (ny < 0 || m <= ny) continue;
      if (maze[nx][ny] == '#') continue;
      if (d[nx][ny] != INF) continue;
      que.push(P(nx, ny));
      d[nx][ny] = d[p.first][p.second] + 1;
    }
  }
  int ans = n*m - cnt - 1 - d[gx][gy];
  if (d[gx][gy]==INF) cout<<-1<<endl;
  else cout<<ans<<endl;
}


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

#define rep(i,n) for(ll i = 0; i < (n); i++)
#define repd(i,n) for(ll i = (n); i >= 0; i--)
#define FOR(i,t,n) for(ll i = (t); i < (n); i++)
#define FORD(i,t,n) for(ll i = (n); i >= t; i--)
#define ALL(x) x.begin(),x.end()
#define asort(x) sort(ALL(x))

int main() {
    string N;
    ll sum = 0;
    cin >> N;
    rep(i,N.size()) {
        sum += (N[i]) - '0';
    }
    if(sum % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3752
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
x, y = map(int, input().split())
print('Yes' if (x in a and y in a) or (x in b and y in b) or (x in c and y in c) else ('No'))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
using namespace std;
int main(){
  string S;
  cin >> S;
  int res = 1e9;
  for(int i = 0; i < S.size() - 2; ++i){
    int x = (S[i] - '0') * 100 + (S[i+1] - '0') * 10 + S[i+2] - '0';
    res = min(res, abs(753 - x));
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
typedef long long ll;
using namespace std;
const int MOD = 1e9 + 7;
int N;
int F[100][14];
int P[100][15];
int main(void) {
	cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 10; j++)cin >> F[i][j];
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 11; j++)cin >> P[i][j];
	}
	int cui = -(1 << 30);
	for (int b = 1; b < (1 << 10); b++) {
		int cc = 0;
		for (int i = 0; i < N; i++) {
			int c = 0;
			for (int j = 0; j < 10; j++) if (((b >> j) & 1)&& F[i][j] == true) {
				c++;
			}
			cc += P[i][c];
		}
		if (cui < cc)cui = cc;
	}
	cout << cui << endl;
	return 0;
}

Measured memory_bytes: 256
//AOJ-0558
#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
using namespace std;

char map[1010][1010];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int vis[1010][1010];
int m, n, N;
struct node{
	int x, y, t;
};

node bfs(int x, int y, char k)
{
	memset(vis, 0, sizeof(vis));
	queue<node> q;
	node s, e, p;
	s = {x, y, 0};
	q.push(s); vis[x][y] = 1;
	while(!q.empty())
	{
		p = q.front(); q.pop();
		if(map[p.x][p.y] == k) return p;
		for(int i = 0; i < 4; i++)
		{
			int nx = p.x + dx[i];
			int ny = p.y + dy[i];
			if(nx >= n || nx < 0 || ny >= m || ny < 0 || map[nx][ny] == 'X') continue;
			if(!vis[nx][ny]){
				vis[nx][ny] = 1;
				e = {nx, ny, p.t + 1};
				q.push(e);
			}	
		}
	}
}


int main()
{
	while(~scanf("%d %d %d", &n, &m, &N))
	{
		node s;
		for(int i = 0; i < n; i++){
			scanf("%s", map[i]);
			for(int j = 0; j < m; j++){
			   if(map[i][j] == 'S'){
			   	 s.x = i; s.y = j; s.t = 0;
			   }
			}	
		}
		int ans = 0;
		char c = '0';
		for(char i = 1; i <= N; i++)
		{
			node t = bfs(s.x, s.y, c + i);
			ans += t.t;
			s.x = t.x; s.y = t.y;
		}
		printf("%d\n", ans);
	}
	return 0; 
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vi vector<ll>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define el printf("\n")
#define pb push_back
#define f first
#define s second
#define arrondi(a) (long long)floor(a+0.5);
#define NIL -1
ll N=500005;
ll MAX=9223372036854775807;
ll MOD=1000000007;
long double PI =4*atan(1);
int f(int a)
{
    string s="";
    for (int i=0;i<a;i++)
        s+="9";
    return atoll(s.c_str());
}
int main()
{
	IOS;
    cout.precision(30);
    int n; cin >> n;
    int c=log10(n)+1;
    if (c%2==0) {c--; n=f(c);}
    ll ans=0;
    for (int i=c;i>=1;i-=2)
    {
        ans+=n-pow(10,i-1)+1;
        n=f(i-2);
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;


//const int mod=1000000007;
const int mod=998244353;



int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d,y,l,r;
    cin >> n;
    vll v(n);
    vll dp(n);
    dp[n-1]=0;
    for(int i=0; i<n; i++)
        cin >> v[i];
    for(int i=n-2; i>=0; i--){
        if(i+1<n){
            dp[i]=dp[i+1]+abs(v[i]-v[i+1]);
        }
        if(i+2<n){
            dp[i]=min(dp[i],dp[i+2]+abs(v[i]-v[i+2]));
        }
    }
    cout << dp[0] << el;
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

    public static void main (String[] args){

        Scanner scanner1 = new Scanner(System.in);
        String str = scanner1.nextLine();

        int ind1 = str.indexOf("C");
        String str2 = str.substring(ind1+1);
        int ind2 = str2.indexOf("F");

        if(ind1>=0 && ind2 >= 0)
            System.out.print("Yes\n");
        else
            System.out.print("No\n");

    }
}


Measured memory_bytes: 10196
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<30)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  string S;
  cin >> S;
  int N=S.size();
  int zero=0;
  int one=0;
  for(int i=0;i<N;i++){
    if(S[i]=='0'){
      zero++;
    }else{
      one++;
    }
  }
  int ans=min(one,zero)*2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        a: i64, v: i64,
        b: i64, w: i64,
        t: i64
    }

    if (b-a).abs() <= (v-w)*t {
        println!("YES");
    } else {
        println!("NO");
    }
}


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

int main(){
	int n,m;
	cin>>n;
	m=n%10;
	
	if(m==2||m==4||m==5||m==7||m==9) cout<<"hon";
	else if(m==0||m==1||m==6||m==8) cout<<"pon";
	else cout<<"bon";
	
	return 0;
} 

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")

#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007;

int main(){
  int n; cin >> n;
  int a[n];
  rep(i, n) cin >> a[i];
  int q; cin >> q;
  int b[q];
  rep(i, q) cin >> b[i];
  sort(a, a+n); sort(b, b+q);
  int i = 0; int j = 0;
  int ans = 0;
  while(i < n && j < n){
    if(a[i] == b[j]){
      ans++; i++; j++;
    }else if(a[i] > b[j]){
      j++;
    }else{
      i++;
    }
  }
  cout << ans << "\n";
}



Measured memory_bytes: 3164
import java.util.*;
 
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int d = sc.nextInt();
        int f = d * 2 + 1;

        if (n % f == 0) {
            System.out.println(n / f);
        } else {
            System.out.println(n / f + 1);
        }
	}
}


Measured memory_bytes: 23124
#include <stdio.h>
#include <ctype.h>
 
int main(void)
{
    char s;
 
    while(1){
        scanf("%c", &s);
        if(islower(s))
            printf("%c", toupper(s));
        else if(isupper(s))
            printf("%c", tolower(s));
        else if(s == '.'){
            printf(".");
        } else if(s == '\n'){
            printf("\n");
            break;
        } else
            printf("%c", s);
    }
    return 0;
}

Measured memory_bytes: 2500
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll A[101],B[101],C[101],D[101];
ll ans;
ll N,M,Q;
void dfs(vector<ll> v)
{
    // cout<<" hi"<<"";
    if(v.size()==N)
    {
        ll sum=0;
        for(ll i=0;i<Q;i++)
        {
            if (v[B[i]-1]-v[A[i]-1]==C[i])
            {
                sum+=D[i];
            }
        }
        ans=max(ans,sum);
    }
    else
    {
        for(ll i=v[v.size()-1];i<=M;i++)
        {
            vector<ll> n=v;
            n.push_back(i);
            dfs(n);
        }
    }
}
int main() 
{  
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ans=INT_MIN;
    cin>>N>>M>>Q;
    for(ll i=0;i<Q;i++)
    {
        cin>>A[i]>>B[i]>>C[i]>>D[i];
    }
    for(ll i=1;i<=M;i++)
    {
        vector<ll> v;
        v.push_back(i);
        dfs(v);
    }
    cout<<ans<<" ";
}

Measured memory_bytes: 3632
#include"bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long INT;
double PI = 3.14159265;

const long long INF = 1LL << 60;
//---//


int main() {
    int a, b, c, d;

    cin >> a>>b>>c>>d;

    if ((c+b-1) / b <= (a+d-1) / d)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3628
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		long A = Long.parseLong(sc.get());
		long B = Long.parseLong(sc.get().replace(".", ""));
		System.out.println(A * B / 100);
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
int main(){
	ios::sync_with_stdio(false);
	LL a,b;
	cin>>a>>b;
	if(a>b)swap(a,b);
	if((b-a)%2)cout<<"IMPOSSIBLE";
	else cout<<(a+(b-a)/2);	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long int lli;
#define REP(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
const lli inf = 1e18;

int main(){
    int n,x;
    cin >> n >> x;
    vector<lli> a(n);
    REP(i, n) cin >> a[i];
    
    lli ans = 0;
    if(a[0] > x){
        ans += a[0]-x;
        a[0] = x;
    }
    REP(i, n-1){
        lli diff = a[i] +a[i+1] -x;
        if(diff > 0){
            ans += diff;
            a[i+1] -= diff;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  vector<int64_t> yakusuu(N + 1, 2);
  yakusuu[0] = 0;
  yakusuu[1] = 1;
  for (int64_t i = 2; i * i <= N; ++i) {
    for (int64_t j = 2 * i; j <= N; j += i) {
      if (i * i <= j) {
        if (i * i == j) {
          ++yakusuu[j];
        } else {
          yakusuu[j] += 2;
        }
      }
    }
  }

  int64_t result = 0;
  for (int64_t K = 1; K <= N; ++K) {
    // cerr << K << ", " << yakusuu[K] << endl;
    result += K * yakusuu[K];
  }
  cout << result << endl;
}


Measured memory_bytes: 81284
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;

int toint(string str){
	stringstream ss;
	int num;
	ss << str;
	ss >> num ;
    return num;
}

string tostring(int num){
	stringstream ss;
		ss << num;
	    return ss.str();
}

string to0string(int L,string str){
	int size = str.size();
	if(size < L){
	for(int i=0;i<(L-size);i++){
		str = '0' + str;
	  }
	}
	return str;
}

int main(){
   int a,L; string str;  stringstream ss;
   while(cin >> a >> L){
	   if(a == 0 && L == 0) break;
	   int num[21];
	   num[0] = a;
	   for(int i=0;;i++){
		   bool flag = false;
		   str = to0string(L,tostring(a));
		    int mx,mn;
	    	sort(str.begin(),str.end());
	    	mn = toint(str);
	        reverse(str.begin(),str.end());
	    	mx = toint(str);
	    	num[i+1] = a = mx -mn;
	    	for(int j=0;j<i+1;j++){
	    		if(num[j]== num[i+1]){
	    					cout<<j<<" "<<num[j]<<" "<<i+1-j<<endl;
	    					flag = true;
	    				}
	    	}
	    	if(flag) break;
	    }
   }
}

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

#define Online 1
// #define multitest 1
#define Debug 1
typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
#define mp make_pair
const long long mod = 1000000007;
const long long High = 1e16;
void ControlIO();
void TimerStart();
void TimerStop();
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
    std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    std::cerr.write(names, comma - names) << " = " << arg1;
    ZZ(comma, args...);
}
#else
#define db(...)
#endif

typedef pair<int, int> pii;
vector<int> P(100005), S(100005);

void init()
{
    for (int i = 0; i < 100005; ++i)
    {
        P[i] = i;
        S[i] = 1;
    }
}

int find(int i)
{
    if (P[i] == i)
        return i;
    return P[i] = find(P[i]);
}

int Un(int u, int v)
{
    u = find(u);
    v = find(v);
    if (u != v)
    {
        if (S[v] > S[u])
            swap(u, v);
        P[v] = u;
        S[u] += S[v];
        return 1;
    }
    return 0;
}

void solve()
{
    int n, u, v, w, m;
    cin >> n >> m;
    init();
    for (int i = 0; i < m; ++i)
    {
        cin >> u >> v >> w;
        if (Un(u, v))
            n--;
    }
    cout << n;
}

int main()
{
    ControlIO();
    int t = 1;
#ifdef multitest
    cin >> t;
#endif
    TimerStart();
    while (t--)
        solve();
    TimerStop();
    return 0;
}

void ControlIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifndef Online
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

auto TimeStart = chrono::steady_clock::now();
auto TimeEnd = chrono::steady_clock::now();

void TimerStart()
{
#ifndef Online
    TimeStart = chrono::steady_clock::now();
#endif
}

void TimerStop()
{
#ifndef Online
    TimeEnd = chrono::steady_clock::now();
    auto ElapsedTime = TimeEnd - TimeStart;
    cout << "\n\nTime elapsed: " << chrono::duration<double>(ElapsedTime).count() << " seconds.\n";
#endif
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define INF 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,n_;
int m;
ll a[5005],b[5005][205];
ll sum[5005][5005];
ll asum[5005];

struct data{
	ll val;
	int x;
	data(){}
	data(ll vv,int xx){
		val=vv;
		x=xx;
	}

	bool operator<(const data& d)const{
		if(val==d.val)return x<d.x;
		return val<d.val;
	}
};

data dat[1<<21];

void update(int k,ll a){
	k+=n_-1;
	dat[k].val=a;
	dat[k].x=k-(n_-1);
	while(k>0){
		k=(k-1)/2;
		dat[k]=max(dat[k*2+1],dat[k*2+2]);
	}
}

data query(int a,int b,int k=0,int l=0,int r=n_){
	//printf("%d %d %d %d %d\n",a,b,k,l,r);
	if(b<=l || r<=a)return data(0,-1);
	if(a<=l && r<=b)return dat[k];
	data vl=query(a,b,k*2+1,l,(l+r)/2);
	data vr=query(a,b,k*2+2,(l+r)/2,r);
	return max(vl,vr);
}

void calc(int l,int r){
	if(l>=r)return;
	data d=query(l,r);
	sum[l][d.x]+=d.val;
	sum[l][r]-=d.val;
	sum[d.x+1][d.x]-=d.val;
	sum[d.x+1][r]+=d.val;
	calc(l,d.x);
	calc(d.x+1,r);
}


int main(void){
	scanf("%d%d",&n,&m);
	n_=1;
	while(n_<n)n_*=2;
	for(int i=0;i<n-1;i++){
		scanf("%lld",&a[i]);
		asum[i+1]=asum[i]+a[i];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			scanf("%lld",&b[i][j]);
		}
	}
	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			update(j,b[j][i]);
		}
		calc(0,n);
	}
	for(int i=0;i<=n;i++){
		for(int j=1;j<=n;j++){
			sum[i][j]+=sum[i][j-1];
		}
	}
	for(int i=0;i<=n;i++){
		for(int j=1;j<=n;j++){
			sum[j][i]+=sum[j-1][i];
		}
	}
	ll res=0;
	for(int i=0;i<n;i++){
		for(int j=i;j<n;j++){
			res=max(res,sum[i][j]-(asum[j]-asum[i]));
		}
	}
	printf("%lld\n",res);
	return 0;
}


Measured memory_bytes: 204288
#include<stdio.h>

int i; int num1=0; int num2=0; int num3=0;
int main(void){
	char str[100];
	scanf("%s",str);
	
	for(i=0;i<100;i++){
		if(str[i] == 'a'){
			num1++;}}
    for(i=0;i<100;i++){
		if(str[i] == 'b'){
			num2++;}}
	for(i=0;i<100;i++){
		if(str[i] == 'c'){
			num3++;}}
	if(num1==1&&num2==1&&num3==1){
		printf("Yes");}
	else{printf("No");}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

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

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

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////



int main() {

	ll N,A,B;
	cin >> N >> A >> B;

	vector<ll> v(N + 1);
	repn(i, N) cin >> v[i];

	sort(++v.begin(), v.end(), greater<ll>());

	ll X = v[A];

	ll s = 0;
	repn(i, A) s += v[i];

	double av = (double)s / (double)A;

	ll a, b;
	repn(i, N) {
		if (v[i] == X) { a = i; break; }
	}

	for (ll i = N; i > 0; i--) {
		if (v[i] == X) { b = i; break;}
	}

	ll com[51][51] = {};
	
	rep(i, 51) { com[i][0] = 1; }

	repn(i, 50)repn(j, 50) { com[i][j] = com[i - 1][j] + com[i - 1][j - 1]; }

	ll ans=0;

	if (a != 1) {
		ans = com[ b- a + 1][ A - a + 1];
	}

	if (a == 1) {
		ll t = min(B, b);
		for(ll i=A; i<=t; i++) ans += com[b][i];

	}

	cout << fixed << setprecision(10);

	cout << av << endl << ans;


	
	system("PAUSE");
}


Measured memory_bytes: 504
#include <stdio.h>
int main(){
  int size;
  scanf("%d",&size);
  
  int num[size],i;
  
  for(i=0;i<size;i++){
    scanf("%d",&num[i]);
  }
  int s=0;
  for(i=1;i<size-1;i++){
    if((num[i-1]<num[i]&&num[i]<num[i+1])||(num[i+1]<num[i]&&num[i]<num[i-1])) s++;
  }
  printf("%d\n",s);
  return 0;
}


Measured memory_bytes: 128
/////////////////////////////////TEST CASES////////////////////////////////////
/*
*/
/////////////////////////////////////CODE//////////////////////////////////////		
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = a ; i > b ; i--)
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define PI 3.14159265
typedef long long ll;
#define vl vector<ll> 
#define IN(inp) ll inp;cin>>inp;
#define pb push_back
#define all(a) a.begin(),a.end()
#define FR(i,a) for(auto i:a)
#define what(A) cout<<#A<<" is "<<A<<endl;
ll MAX = 100000000000;
ll MOD = 1000000007;
ll h, w;
ll dp[1001][1001], vis[1001][1001];
char mat[1001][1001];
ll go(ll x, ll y)
{
	if (x == h-1 and y == w-1)
		return 1;
	if (x >= h or y >= w or mat[x][y] == '#')
		return 0;
	if (vis[x][y] != 0)
		return dp[x][y]%MOD;
	vis[x][y] = 1;
	dp[x][y] = (go(x+1,y)+go(x,y+1));
	return (dp[x][y]>=MOD?(dp[x][y]-MOD):dp[x][y]);
}
void solve()
{
	cin >> h >> w;
	FOR(i, 0, h)
	{
		FOR(j, 0, w)
		{
			cin >> mat[i][j];
		}
	}
	cout << go(0, 0);
}
int main()
{
	fastio
		//freopen("input.txt", "rt", stdin);
		//freopen("output.txt", "wt", stdout);
		ll test = 1;
	//cin >> test;
	while (test--)
	{
		solve();
	}
}

Measured memory_bytes: 20224
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define llong long long
using namespace std;

const int N = 4000;
struct Edge
{
	int v,nxt;
} e[(N<<1)+2];
int fe[N+3];
int fa[N+3];
int dep[N+3];
int n,m,en;

void addedge(int u,int v)
{
	en++; e[en].v = v;
	e[en].nxt = fe[u]; fe[u] = en;
}

int dfs(int u)
{
	if(dep[u]>m) return 0;
	int ret = (u<=n);
	for(int i=fe[u]; i; i=e[i].nxt)
	{
		if(e[i].v==fa[u]) continue;
		fa[e[i].v] = u;
		dep[e[i].v] = dep[u]+1;
		ret += dfs(e[i].v);
	}
	return ret;
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1; i<n; i++)
	{
		int x,y; scanf("%d%d",&x,&y);
		addedge(x,i+n); addedge(i+n,x);
		addedge(y,i+n); addedge(i+n,y);
	}
	int ans = 0;
	for(int i=1; i<=n+n-1; i++)
	{
		fa[i] = 0; dep[i] = 0;
		int tmp = dfs(i);
		ans = max(ans,tmp);
	}
	ans = n-ans;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

  vector<vector<int>> v(m);

  rep(i,n) {
    int a, b;
    cin >> a >> b;
    if(a > m) { 
        continue;
    }
    v[m-a].push_back(b);
  }

  priority_queue<int> prQ;

  ll ans = 0;
  for (int i = m-1; i >= 0; i--) {
    rep(j, v[i].size()) {
      prQ.push(v[i][j]);
    }

    if (!prQ.empty()) {
      ans += prQ.top();
      prQ.pop();
    }
  }

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

Measured memory_bytes: 5504
def prime_factorization(num):
    f = 2
    factor = []
    while num > 1:
        if num % f == 0:
            factor.append(f)
            num //= f
            f = 2
        else:
            f += 1
    return {d: factor.count(d) for d in set(factor)}
N = int(input())
pff = {}
while N > 1:
    pf = prime_factorization(N)
    for k in iter(pf.keys()):
        if k in pff:
            pff[k] += pf[k]
        else:
            pff[k] = pf[k]
    N -= 1
threshold = [74, 24, 14, 4, 2]
count = [0] * len(threshold)
for i in iter(pff.values()):
    for j in range(len(threshold)):
        if i >= threshold[j]:
            count[j] += 1
ans = count[0] \
    + count[1] * (count[4] - 1) \
    + count[2] * (count[3] - 1) \
    + (count[3] * (count[3] - 1) // 2 * (count[4] - 2))
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void) {
	int n;
	cin >> n;
	vector<int> dp(n+10,10000000);dp[0]=0;
	for(int i=0; i<=n; i++){
		dp[i+1]=min(dp[i+1],dp[i]+1);
		for(int j=6; i+j<=n; j*=6)dp[i+j]=min(dp[i+j],dp[i]+1);
		for(int j=9; i+j<=n; j*=9)dp[i+j]=min(dp[i+j],dp[i]+1);
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 640