akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <map>
#include <cstdio>

using namespace std;


int main() {

  int n,m;
  map<char,char> conv;

  string data;
  
  
  while(cin >> n) {

    if(n==0) break;

    conv.clear();

    for(int i=0;i<n;i++) {

      char tmp1,tmp2;

      cin >> tmp1 >> tmp2;

      conv[tmp1]=tmp2;

    }

    cin >> m;

    for(int i=0;i<m;i++) {

      char tmp3;

      cin >> tmp3;

      if(conv[tmp3]) cout << conv[tmp3];

      else cout << tmp3;

    }

    cout << endl;

  }

  return 0;

}

Measured memory_bytes: 904
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int k = sc.nextInt();
		sc.close();

		for (int x = 0; x <= k; x++) {
			for (int y = 0; y <= k; y++) {
				for (int z = 0; z <= k; z++) {
					if (x + y + z <= k) {
						int ax = a * (1 << x);
						int by = b * (1 << y);
						int cz = c * (1 << z);
						if (ax < by && by < cz) {
							System.out.println("Yes");
							return;
						}
					}
				}
			}
		}
		System.out.println("No");
	}
}


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

typedef long long ll;
ll S, a, b, c, d, p;

void getAB() {
    if (p * p == S) a = d = p;
    else a = d = p + 1;
}

int main() {
    cin >> S;
    p = sqrt(S);
    getAB();
    ll t = a * d - S;
    rep(i, 1, 1e9)
        if (t % i == 0 && t / i <= 1e9) { b = i, c = t / i; break; }
    printf("0 0 %lld %lld %lld %lld\n", a, b, c, d);
    return 0;
}


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

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int K, A, B;
  cin >> K >> A >> B;

  if(A <= B/K*K) cout << "OK" << "\n";
  else cout << "NG" << "\n";

  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
using namespace std;
#define endl '\n'
#define pi pair<int, int>

const int k = 100001;
int n, m;
long long dp[k];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n >> m;
	
	long long ret = 0;
	memset(dp, 0x3f3f3f3f, sizeof(dp));
	dp[0] = 0;
	for(int i = 0; i < n; i++){
		long long w, v;
		cin >> w >> v;
		for(int j = k - v - 1; j >= 0; j--){
			dp[j + v] = min(dp[j + v], dp[j] + w);
			if(dp[j + v] <= m) ret = max(ret, j + v);
		}
	}
	
	cout << ret << endl;

	return 0;
}

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

#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define repp(i, n) rep(i, n)
#define reppp(i, n) repp(i, n)
#define rrepp(i, n) rrep(i, n)
#define repss(i, n) reps(i, n)
#define repcc(i, n) repc(i, n)
#define repii(i, a, b) repi(i, a, b)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int n, a, b; cin >> n >> a >> b;
  cout << min(n * a, b) << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=101;
string s[N];
int dp[N][N],visit[N][N];
int n,m,cur_i,cur_j,_count;
void dfs(int i,int j){
	if(visit[i][j]==_count)	return;
	visit[i][j]=_count;
	if(i>=n || j>=m)	return;
	if(s[i][j]=='#'){
		dp[cur_j][cur_j]=min(dp[cur_j][cur_j],1+dp[i][j]);
	}else	return ;
	dfs(i+1,j);dfs(i,j+1);
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	
	cin>>n>>m;
	for(int i=0;i<n;i++)	cin>>s[i];
	dp[n-1][m-1]=(s[n-1][m-1]=='#')?1:0;

	for(int i=m-2;i>=0;i--){
		if(s[n-1][i]=='#' && s[n-1][i+1]=='.')	dp[n-1][i]=1+dp[n-1][i+1];
		else	dp[n-1][i]=dp[n-1][i+1];
	}
	for(int i=n-2;i>=0;i--){
		if(s[i][m-1]=='#' && s[i+1][m-1]=='.')	dp[i][m-1]=1+dp[i+1][m-1];
		else	dp[i][m-1]=dp[i+1][m-1];
	}
	// int count=0;
	for(int i=n-2;i>=0;i--){
		for(int j=m-2;j>=0;j--){
			if(s[i][j]=='.'){
				dp[i][j]=min(dp[i+1][j],dp[i][j+1]);
			}else{
				cur_i=i,cur_j=j;
				dp[i][j]=N*N;
				if(s[i][j]=='#' && s[i][j+1]=='.')	dp[i][j]=min(dp[i][j],1+dp[i][j+1]);
				else								dp[i][j]=min(dp[i][j],dp[i][j+1]);
				if(s[i][j]=='#' && s[i+1][j]=='.')	dp[i][j]=min(dp[i][j],1+dp[i+1][j]);
				else								dp[i][j]=min(dp[i][j],dp[i+1][j]);
				_count++;
				dfs(i+1,j);dfs(i,j+1);
			}
		}
	}
	cout<<dp[0][0]<<"\n";
	return 0;
}

Measured memory_bytes: 384
from collections import deque
import sys


def bfs(x1, y1, d):
    q = deque()
    q.append((d, x1, y1))

    while q:
        d, x1, y1 = q.popleft()

        M[x1][y1] = d

        if [x1, y1] == [xg, yg]:
            print(d)
            return

        for dx, dy in ((0, 1), (1, 0), (0, -1), (-1, 0)):
            for k in range(1, K + 1):
                x2 = x1 + dx * k
                y2 = y1 + dy * k

                if (0 <= x2 < H) and (0 <= y2 < W):
                    if m[x2][y2] == '@':
                        break
                    elif M[x2][y2] == -1:
                        M[x2][y2] = d + 1
                        q.append((d + 1, x2, y2))
                    elif M[x2][y2] < d + 1:
                        break
                else:
                    break
    print(-1)


H, W, K = map(int, input().split())
xs, ys, xg, yg = map(int, input().split())
xs, ys, xg, yg = xs - 1, ys - 1, xg - 1, yg - 1

m = []
for i in range(H):
    m.append(list(map(str, sys.stdin.readline().strip())))

M = [[-1] * W for i in range(H)]

bfs(xs, ys, 0)


Measured memory_bytes: 45256
#import<iostream>
#import<algorithm>
long long i,j,n,x,m=1000000007,s[200],d[100001];
main(){std::cin>>n>>x;for(i=0;i!=n;++i)std::cin>>s[i];std::sort(s,s+n);for(i=0;i<=x;++i)d[i]=i;for(i=0;i!=n;++i){for(j=x;j;--j)d[j]=(d[j]*i+d[j%s[i]])%m;}std::cout<<d[x];}


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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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

template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
///////////////////////////////////////////////
/*（๑•﹏•๑｀) */
int main(){
    ll r,D,x;
    cin >> r >> D >> x;
    REP(i,10){
        x = r * x - D;
        cout << x << "\n";
    }

}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
const int N = 2 * 1e5 + 10;

int n, a[N];

int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
    }
    int j = 1;//右端点
    long long suma = 0, sumb = 0, ret = 0;//suma: XOR  sumb: 和
    for(int i = 1; i <= n; i++){//枚举左端点
        while(j-1 <= n && suma == sumb){//滑动右端点
            suma ^= a[j], sumb += a[j];//一波操作666？？
            j++;//右端点往右移
        }
        ret += j - i - 1;
        //跳出循环是因为j位置的2个数不符合条件，所以将这2个位置从suma和sumb中剔除
        suma ^= a[j-1], sumb -= a[j-1];
        //左端点会往右移，所以将最左边的2个位置从suma和sumb中剔除
        suma ^= a[i], sumb -= a[i];
        //跳出循环是因为j位置的2个数不符合条件，所以j-1是满足条件的最右位置
        j--;
    }
    printf("%lld\n", ret);
    return 0;
}

Measured memory_bytes: 896
#include<stdio.h>
int main() {
	int i, n, deb=100000;
	scanf("%d", &n);
	for (i = 0;i < n;i++) {
		deb *= 1.05;
		if (deb % 1000 != 0) {
			deb += 1000;
		}
		deb = deb / 1000 * 1000;
	}
	printf("%d\n", deb);
	return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
bitset<4000001> b;
string s;
int n,a[20001],sum;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i],sum+=a[i];
    b=1;
    for(int i=1;i<=n;i++)
    {
        b=b|(b<<a[i]);
    }
    for(int i=(sum+1)>>1;1;++i)
    {
        if(b[i]){cout<<i<<endl;return 0;}
    }
    return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	string s,w,p;
	cin>>s>>w;
	int a[s.size()+1][w.size()+1];
	for(int i = 0;i< (int)s.size()+1;i++)
	{
		for(int j =0; j < (int)w.size()+1;j++)
		{
			if(i==0 || j==0)
				a[i][j] = 0;
			else if(s[i-1] != w[j-1])
				a[i][j] = max(a[i-1][j],a[i][j-1]);
			else
				a[i][j] = a[i-1][j-1]+1;
		}
	}
	int i = s.size(),j = w.size();
	while(i >=1 && j>=1)
	{
		if(s[i-1] == w[j-1])
		{
			p.push_back(s[i-1]);
			i--;
			j--;
		}
		else
		{
			if(a[i-1][j] >= a[i][j-1])
				i--;
			else
				j--;
		}
	}
	reverse(p.begin(),p.end());
	cout<<p<<endl;
	return 0;
}


Measured memory_bytes: 38796
'use strict'
function main(inp) {
  inp = inp.trim().split('\n');
  let bingoPaper = [];
  bingoPaper.push(...inp[0].split(' '),...inp[1].split(' '),...inp[2].split(' '));
  let N = inp[3]*1;
  let rest = inp.slice(4,4 + N);
  // まずは印付
  for(let i = 0; i < N; i++){
  	if(bingoPaper.indexOf(rest[i]) >= 0){
 		   bingoPaper[bingoPaper.indexOf(rest[i])] = -1;
    }
  }
  // ビンゴかどうかの確認
  // jadgeはincludesが使いたいので文字列に（この条件なら大丈夫なはず）
  let jadge = "";
  for(let j = 0; j < 9; j++){
    if(bingoPaper[j] == -1){
    	jadge += j;
    }
  }
  let ans ="No";
  // あとはひたすら条件分の列挙
  // 横列判定系
  if(jadge.includes(0) && jadge.includes(1) && jadge.includes(2)){
  	ans = "Yes";
  }
  if(jadge.includes(3) && jadge.includes(4) && jadge.includes(5)){
  	ans = "Yes";
  }
  if(jadge.includes(6) && jadge.includes(7) && jadge.includes(8)){
  	ans = "Yes";
  }
  // 縦判定
  if(jadge.includes(0) && jadge.includes(3) && jadge.includes(6)){
  	ans = "Yes";
  }
  if(jadge.includes(1) && jadge.includes(4) && jadge.includes(7)){
  	ans = "Yes";
  }
  if(jadge.includes(2) && jadge.includes(5) && jadge.includes(8)){
  	ans = "Yes";
  }
  // 斜め判定
  if(jadge.includes(0) && jadge.includes(4) && jadge.includes(8)){
  	ans = "Yes";
  }
  if(jadge.includes(2) && jadge.includes(4) && jadge.includes(6)){
  	ans = "Yes";
  }
  
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define PI 3.141592653589793238
int main()
{
    // #ifndef ONLINE_JUDGE
    // freopen("F:/cpp/input.txt", "r", stdin);
    // freopen("F:/cpp/output.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a, b;
    cin >> a >> b;
    cout << a*b;
    return 0;
}

Measured memory_bytes: 3648
N, W = map(int, input().split())
wt, vt = [], []
for _ in range(N):
    w, v = map(int, input().split())
    wt.append(w)
    vt.append(v)

dp = [[0] * (W + 5) for _ in range(105)]

for i in range(N):
    for j in range(W + 1):
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
        if 0 <= j - wt[i]:
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - wt[i]] + vt[i])
# print(dp)
print(dp[N][W])

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


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



int main(){
    ll ans=MAX,h,n;
    cin>>h>>n;

    ll dp[h+10005];//kダメージ与えるのに必要な最低MP

    //vector< pair<ll ll> > mahou;
    for(int i=0;i<h+10005;i++){
        dp[i]=MAX;
    }
    dp[0]=0;
    for(int i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        for(int j=0;j<=h+10000;j++){
            if(j-a<0)continue;
            dp[j]=min(dp[j],dp[j-a]+b);
        }
    }
    for(int i=h;i<=h+10000;i++){
        if(dp[i]==MAX)continue;
        // cout<<dp[i]<<endl;
        ans=min(dp[i],ans);
    }

    cout <<ans<<endl;

    return 0;

}

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

int avail(int depth, int sum, int minval) {
	if (depth == 0)
		return (sum == 0 ? 1 : 0);

	int ret = 0;
	for (int i = minval; i <= 9 && i <= sum; i++)
		ret += avail(depth-1, sum-i, i+1);
	return ret;
}

int main() {
	int n, s;
	while (cin >> n >> s, n||s) {
		cout << avail(n, s, 0) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define vi vector<int>
#define ll long long
#define pb push_back
#define ii pair<int, int>
#define qi queue<int>
#define si stack<int>
#define mii map<int, int>
#define msi map<string, int>
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
using namespace std;

const int MAX = 1e5+5;
const int mod = 1e9+7;

int low[MAX], tin[MAX];

vi adj[MAX];
bitset<MAX> visited;

int timer = 0, ctr = 0;

void dfs(int u, int p = -1) {

	visited[u] = 1;

	low[u] = tin[u] = timer++;

	for (int v : adj[u]) {
		if (v == p)
			continue;
		
		if (visited[v]) 
			low[u] = min(low[u], tin[v]);
		else {
			dfs(v, u);

			low[u] = min(low[u], low[v]);

			if (low[v] > tin[u])
				ctr++;
		}
	}

}

int main(int argc, char** argv) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	//#ifndef ONLINE_JUDGE
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//#endif

	int n, m, u, v;
	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		cin >> u >> v;
		adj[u].pb(v);
		adj[v].pb(u);
	}

	dfs(1);

	cout << ctr;

	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
  int n,k;
  cin >> k >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int dif = 0;
  rep(i,n) {
    int sa;
    if(i == n-1) sa = a[0] - a[n-1] + k;
    else sa = a[i + 1] - a[i];
    dif = max(dif,sa);
    
  }
  cout << k - dif << endl;
}

Measured memory_bytes: 4056
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define INF 100000000


int main(){
    int N, M;
    cin >> N >> M;
    int dist_orig[100][100] = {}, dist[100][100] = {};
    int path[1000][3] = {};
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(i == j){
                dist[i][j] = 0;
            }else{
                dist[i][j] = INF;
            }
        }
    }
    for(int i = 0; i < M; i++){
        int a, b, c;
        cin >> a >> b >> c;
        dist[a-1][b-1] =
        dist[b-1][a-1] = c;
        path[i][0] = a-1;
        path[i][1] = b-1;
        path[i][2] = c;
    }
    for(int k = 0; k < N; k++){
        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++){
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < M; i++){
        if(dist[path[i][0]][path[i][1]] < path[i][2]){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
<?php
  $n=fgets(STDIN);
  if ($n<10){
    echo Yes;
    exit();
  }
  for ($i=2;$i<10;$i++){
    if($n%$i==0 && 1<$n/$i && $n/$i<10){
      echo Yes;
      exit();
    }
  }
  echo No;

Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <bitset>
using namespace std;

#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)
#define iter(it,c) for(auto it=(c).begin(); it!=c.end(); ++it)

typedef vector<int> vi;
typedef map<int, int> mii;

int const score[] = { 0, 0, 60, 70, 80 };
int eval(int n){
    int s = 0;
    rep(i, 5){
        s += score[n & 7];
        n >>= 3;
    }
    return s;
}

int flip(int n, int f){
    f <<= 2;
    int r = 0;
    rep(i, 5){
        int t = n >> (i * 3) & 7;
        if (t){
            int c = (f >> (i * 2) & 3) + (f >> (i * 2 + 2) & 3);
            t = ((t - 1 + c) & 3) + 1;
        }
        r |= t << (i * 3);
    }
    return r;
}

int solve(vi const& v){
    mii prev;
    prev[v[0]] = eval(v[0]);
    rep(i, 4){
        mii next;
        iter(it, prev){
            int bef = eval(it->first);
            rep(f, 1 << 8){
                int aft = flip(it->first, f);
                int suc = flip(v[i + 1], f);
                int e = it->second - bef + eval(aft) + eval(suc);
                int x = eval(aft);
                int y = eval(suc);
                if (e % 10 != 0){
                    continue;
                }
                next[suc] = max(next[suc], e);
            }
        }
        swap(prev, next);

        /*
        iter(it, prev){
            cout << bitset<15>(it->first) << " " << it->second << endl;
        }
        cout << endl;
        */
    }

    int ans = 0;
    iter(it, prev) ans = max(it->second, ans);
    return ans;
}

int main(){
    int n; cin >> n;
    while (n--){
        vi v(5);
        rep(i, 5){
            rep(j, 5){
                int t = 0; cin >> t;
                v[i] <<= 3;
                v[i] |= t;
            }
        }
        cout << solve(v) << endl;
    }
}

Measured memory_bytes: 1220
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>
#include<iomanip>
#include<string>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define setp(n) fixed<<setprecision(n)


int num[100010];

int main(){
    int Q;
    int N;
    string s;
    cin>>N>>Q>>s;
    for(int i=0;i<N;i++){
        if(s[i-1]=='A'&&s[i]=='C'){
           num[i+1]+=num[i]+1; 
        }
        else{
            num[i+1]+=num[i];
        }
    }
    rep(i,Q){
        int l,r;
        cin>>l>>r;
        cout<<endl;
        cout<<num[r]-num[l];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 1408
#include <bits//stdc++.h>
using namespace std;
int main(void){
    int H,W;
    cin >>H>>W;
    vector<vector<char>>data(H,vector<char>(W));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> data[i][j];
        }
    }
    vector<vector<char>>A(H,vector<char>(W,'-'));
    vector<vector<char>>B(H,vector<char>(W,'-'));
    int r=0;
    //縦消し
    for(int i=0;i<H;i++){
        bool erase = true;
        for(int j=0;j<W;j++){
            if(data[i][j]=='#'){
                erase = false;
            }
        }
        if(erase==false){
            for(int j=0;j<W;j++){
                A[r][j]=data[i][j];
                }
            r++;
        }
    }
    //横消し
    int s=0;
    for(int j=0;j<W;j++){
        bool erase = true;
        for(int i=0;i<H;i++){
            if(A[i][j]=='#'){
                erase = false;
            }
        }
        if(erase==false){
            for(int i=0;i<H;i++){
                B[i][s]=A[i][j];
                }
            s++;
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(B[i][j]!='-'){
                cout << B[i][j];
                if(j==W-1 || B[i][j+1]=='-'){
                    cout <<endl;
                }
                
            
            }
        }
    }
}


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

int main() {
int N ;
 cin >> N ;
bool buy=false;  
  for (int i=0; i<=N/4; i++){
   for (int j=0; j<=N/7; j++){
    if (4*i+7*j==N) buy=true;
   }
  }
  if (buy==true) {
    cout << "Yes" << endl;
	}
  else cout << "No" << endl;
  
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	int N; scanf("%d", &N);
	int A[200001],cpy[200001];
	for (int i = 0; i < N; i++){
		scanf("%d", A + i);
		cpy[i] = A[i];
	}

	sort(cpy, cpy + N);

	for (int i = 0; i < N; i++){
		if (A[i] != cpy[N - 1]){
			printf("%d\n", cpy[N - 1]);
		}
		else{
			printf("%d\n", cpy[N - 2]);
		}
	}

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 3072
#include <iostream>

using namespace std;

int main() {
    int r = 0;
    int c = 0;
    cin >> r;
    cin >> c;
    int table[r + 1][c + 1];

    for (int i = 0; i < r + 1; i++) {
        for (int j = 0; j < c + 1; j++) {
            table[i][j] = 0;
        }
    }

    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            cin >> table[i][j];
        }
    }

    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            table[i][c] += table[i][j];
        }
    }
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c + 1; j++) {
            table[r][j] += table[i][j];
        }
    }


    for (int i = 0; i < r + 1; i++) {
        for (int j = 0; j < c + 1; j++) {
            cout << table[i][j];
            if(j==c){
                break;
            }
            cout<<" ";
        }
        cout << endl;
    }


}

Measured memory_bytes: 3112
#include <stdio.h>

int main(void) {
    unsigned int S;
    scanf("%u", &S);

    unsigned int h, m, s;
    s = S % 60;
    m = (S / 60) % 60;
    h = S / 60 / 60; 
    printf("%u:%u:%u\n", h, m, s);

    return 0;
}

Measured memory_bytes: 604
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#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;
typedef pair<int, int> P;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define SP cout << fixed << setprecision(10)
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
    // code

    int h, w;
    cin >> h >> w;
    int c[10][10];
    rep(i, 10) rep(j, 10) cin >> c[i][j];

    rep(k, 10) {
        rep(i, 10) {
            rep(j, 10) {
                if (c[i][j] > c[i][k] + c[k][j]) {
                    c[i][j] = c[i][k] + c[k][j];
                }
            }
        }
    }

    int sum = 0;
    rep(i, h) {
        rep(j, w) {
            int a;
            cin >> a;
            if (a >= 0) {
                sum += c[a][1];
            }
        }
    }

    cout << sum << endl;

    return 0;
}

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

int main(void){
    int n;
    scanf("%d", &n);
    //std::cin >> n;
    std::vector<int> a(n);
    int v, j;

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

        for(auto i : a){
        std::cout << i;
        if(i != a[n-1]){
            std::cout << " ";
        }
    }
    std::cout << std::endl;

        v = a[i];
        j = i - 1;
        while(j >= 0 && a[j] > v){
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;

        
    }

    for(auto i : a){
        std::cout << i;
        if(i != a[n-1]){
            std::cout << " ";
        }
    }
    std::cout << std::endl;
    
    return 0;
}


Measured memory_bytes: 3208
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

struct vec{
  double x, y;
  vec operator+(const vec& a) const { return (vec){x + a.x, y + a.y}; }
  vec operator-(const vec& a) const { return (vec){x - a.x, y - a.y}; }
  vec sca(double t){ return (vec){t * x, t * y}; }
  double dot(vec a){ return x * a.x + y * a.y; }
  double cross(vec a){ return x * a.y - y * a.x; }
  double norm(){ return x * x + y * y; };
};
struct line{
  vec a, b;
  vec getvec(){ return b - a; }
  vec proj(vec p){
    vec pa = p - a, ba = b - a;
    double t = pa.dot(ba) / ba.norm();
    return a + ba.sca(t);
  }
  vec vref(vec p){ return proj(p).sca(2.0) - p; }
};

signed main(void){
  int i, j, k;
  line l;
  cin >> l.a.x >> l.a.y >> l.b.x >> l.b.y;
  int(q);
  for(;q--;){
    vec p;
    cin >> p.x >> p.y;
    vec res = l.vref(p);
    printf("%.15lf %.15lf\n", res.x, res.y);
  }

  return 0;
}

Measured memory_bytes: 1276
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  string s;cin>>s;
  n=s.length();
  int noflag=0;
  REP(i,n){
	  int flag=0;
	  if (i%2==1){
		  if (s[i]=='L')flag=1;
		  
	  }else{
		  if (s[i]=='R')flag=1;
		  
	  }
	  if (s[i]=='U')flag=1;
	  if (s[i]=='D')flag=1;
	  if (flag==0){
		  noflag=1;
      }
  }

  if (noflag==1){
cout<<"No"<<endl;
  }else{
	  cout<<"Yes"<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        int a[][] = new int[N][2];
        for(int i = 0; i < N; i++){
            a[i][0] = sc.nextInt();
            a[i][1] = sc.nextInt();
        }

        String ans = "No";

        for(int i = 0; i < N - 2; i++){
            if(a[i][0] == a[i][1] && a[i+1][0] == a[i+1][1] && a[i+2][0] == a[i+2][1]){
                ans = "Yes";
                break;
            }
        }

        System.out.println(ans);

        sc.close();
    }
}

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

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

int main() {
	int N;
	cin >> N;
	if (N <= 999) {
		cout << "ABC";
	}
	else {
		cout << "ABD";
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define forin(x,y) for(ll i=x;i<y;i++)
#define vii vector<ll>
#define pii  pair<ll,ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf 1e17
#define mod (ll)(1e9 + 7)
using namespace __gnu_pbds;
using namespace std;

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

void evaluate()
{
    ;
}
int main()
{
    ios::sync_with_stdio(false);    cin.tie(0);     cout.tie(0);
    ll  n,k;
    cin>>n>>k;
    ll min=0,max=0; ll ans = 0;
    forin(0,k)
    {
        min += i;
        max += n-i;
    }
    ans += max - min+1;
    forin(k,n+1)
    {
        min += i;
        max+= n-i;
        ans += max-min+1;
    }
    cout<<ans%mod<<endl;
}


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

typedef pair<int, int> P;
int H,W;
int dx[4]={1,-1,0,0} , dy[4]={0,0,1,-1};
//d[x][y]
int d[1000][1000];
//maze[x][y]
char maze[1000][1000];
int nowNum=0;
char ch;

int bfs(){
    queue<P> que;
    for(int i=0;i<H;i++){
        for(int a=0;a<W;a++){
            d[a][i]=0;
            cin>>ch;
            maze[a][i]=ch;
        }
    }
    for(int i=0;i<H;i++){
        for(int a=0;a<W;a++){
            if(0<=a&&a<W&&0<=i&&i<H&&maze[a][i]=='#'){
                que.push(P(a,i));
                maze[a][i]='#';
                d[a][i]=0;
            }
        }
    }
    while (que.size()) {
        P p= que.front(); que.pop();
        for(int i=0;i<4;i++){
            int nx=p.first+dx[i];int ny = p.second+dy[i];
            if(0<=nx&&nx<W&&0<=ny&&ny<H&&maze[nx][ny]!='#'&&d[nx][ny]==0){
                que.push(P(nx,ny));
                maze[nx][ny]='#';
                d[nx][ny]=d[p.first][p.second]+1;
                nowNum=max(nowNum,d[nx][ny]);
            }
        }
    }
    return 0;
}

int main() {
    cin>>H;
    cin>>W;
    int res = bfs();
    cout << nowNum<< endl; // prints !!!Hello World!!!
    return 0;
}

Measured memory_bytes: 13328
#include<cstdio>
#include<queue>
#include<vector>
#include<utility>

const int INF=999999999;

typedef std::pair<int,int> path_t;//first->node second->cost

struct nodes{
		int cost,num;
		std::vector<path_t> path;
		bool visited=false;
};
bool operator>(const nodes& node_a,const nodes& node_b){
		return node_a.cost>node_b.cost;
}
std::priority_queue<nodes,std::vector<nodes>,std::greater<nodes> > pq;

int v,e,r;
nodes node[100000];

void initialize(void){
	for(int lp=0;lp<100000;lp++){
		node[lp].cost=INF;
		node[lp].num=lp;
	}
}

void input(void){
	int s,t,d;
	scanf("%d%d%d",&v,&e,&r);
	for(int lp=0;lp<e;lp++){
		scanf("%d%d%d",&s,&t,&d);
		node[s].path.push_back(std::make_pair(t,d));
	}
}
void solve(void){
	node[r].cost=0;
	node[r].visited=true;
	pq.push(node[r]);
	while(!pq.empty()){
		nodes node_now=pq.top();
		pq.pop();
		for(int lp=0;lp<(int)node_now.path.size();lp++){
			int nextcost=node_now.path[lp].second+node_now.cost;
			int nextnode=node_now.path[lp].first;
			//printf("nownode:%d nowcost:%d nextnode:%d nextcost:%d\n",node_now.num,node_now.cost,nextnode,nextcost);
			if(node[nextnode].visited==false && nextcost<node[nextnode].cost){
				node[nextnode].cost=nextcost;
				pq.push(node[nextnode]);
			}
		}
	}
}

void output(void){
	for(int lp=0;lp<v;lp++){
		if(node[lp].cost==INF){
			printf("INF\n");
		}else{
			printf("%d\n",node[lp].cost);
		}
	}
}

int main(void){
	initialize();
	input();
	solve();
	output();
	return 0;
}




Measured memory_bytes: 25500
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	s := getNextString(scanner)
	n := len(s)
	f := "FESTIVAL"
	fmt.Fprintln(writer, s[0:n-len(f)])
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

int main(){
  int N;
  cin>>N;
  int T,A;
  cin>>T>>A;
  int H[N],t[N];
  rep(i,N)
    cin>>H[i];
  rep(j,N){
    t[j]=1000*T-(H[j]*6);
    //  cout<<t[j]<<endl;
  }

  int m=1000000;
  rep(i,N)
    m=min(m,abs(t[i]-1000*A));
  // cout<<m<<endl;
  rep(i,N){
    // cout<<t[i]<<endl;
    if(m==abs(t[i]-1000*A))
      cout<<i+1<<endl;
  }


  return 0;
}


Measured memory_bytes: 256
from string import ascii_lowercase
s = input()

if s == ascii_lowercase[::-1]:
    print(-1)
elif len(s)!=len(ascii_lowercase):
    s1 = set(list(s))
    s2 = set(list(ascii_lowercase))
    w = min(s2-s1)
    print(s+w)
else:
    back = ''
    tmp = ''
    pos = 0
    for i in range(len(s))[::-1]:
        if i==25:
            back += s[i]
            tmp = s[i]
        elif s[i]>tmp:
            back += s[i]
            tmp = s[i]
        else:
            pos = i
            break
    
    res = s[:pos]
    w = s[pos]
    l = []
    for b in back:
        if b > w:
            l.append(b)
    print(res + min(l))


Measured memory_bytes: 4020
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

int N, K; 
int solve(){
  if(N*2 < K) return 0;
  if(K%2 == 1){
    return pow(N/K, 3);
  }
  return pow((N-K/2)/K+1, 3)+pow(N/K, 3);
}

signed main() {
  cin >> N >> K;

  cout << solve() << "\n";

  return 0;
}

Measured memory_bytes: 512
import numpy as np
A = int(input())

if A >= 3000:
    print(1)
else:
    a = [100,101,102,103,104,105]
    N = A//100
    dp = np.array([np.array([0 for i in range(A+1)]) for j in range(N+1)])
    dp[0][0] = 1

    for i in range(N):
        for j in np.where(dp[i] == 1)[0]:
        #for j in range(A+1):
           # if dp[i][j] == 1:
            dp[i+1][j+100:j+106] = 1
    print(dp[N][A])

Measured memory_bytes: 12992
#include<bits/stdc++.h>
#define rep(i,n) for(ll i = 0; i < n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e9
using ll = long long;
using namespace std;
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; }

int main(){
  int n; cin >> n;
  vector<bool> change(n+1,false);
  rep(i,n){
    int p; cin >> p;
    if(p == i+1) change[i] = true;
  }

  int cnt = 0;
  rep(i,n){
    if(change[i]){
      cnt++;
      change[i+1]=false;
    }
  }
  cout << cnt;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3640
class dice:
    def __init__(self):
        self.d = list(map(int, input().split()))
        self.dir = list(input())
        
    def move(self):
        up = [0,1,2,3] 
        for a in self.dir:
            if a == "E":
                up = [0, 7-up[3], up[2], up[1]]
            elif a == "W":
                up = [0, up[3], up[2], 7-up[1]]
            elif a == "N":
                up = [0, up[2], 7-up[1], up[3]]
            else:
                up = [0, 7-up[2], up[1], up[3]]
        print(self.d[up[1]-1])
ob = dice()
ob.move()



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

int check(int s, int a){
  int use = 0;
  use += a / 5;
  //cout << "use:" << use << endl;
  if(a % 5 != 0){
  use += 1;
  }
  //cout << "use:" << use << endl;
  if(use <= s){
  return 1;
  }
  else{
  return 0;
  }
}
int main(void){
  int X;
  cin >> X;
  int sho = X / 100;
  int ama = X % 100;
  //cout << "sho:" << sho <<endl;
  //cout << "ama:" << ama <<endl;
  if(ama == 0){
    cout << "1";
  }
  else if(X >= 100 && X <= 105){
    cout << "1";
  }
  else if(X < 100){
    cout << "0";
  }
  else{
    if(check(sho, ama)){
    cout << "1";
    }
    else{
    cout << "0";
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <limits.h>
#include <map>
#include <numeric>

namespace test {
	std::string to_string (char val) {
		return std::string (1, val);
		// return std::string{val};
	}
	//if( str.find ("r") != string::npos)
}

using namespace std;
typedef long long int llint;

int main (void) {
	int a,b; cin >> a >>b;
	if (a % 3 == 0 || b % 3 == 0 || ( a + b ) % 3 == 0) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
	return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int a,b;
  cin>>a>>b;
  if(a>=13) cout<<b;
  else if(a>=6) cout<<b/2;
  else cout<<0;
}

Measured memory_bytes: 256
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int d[101] = {0};

//qsort(a, 3, sizeof(int), sort_inc);
int sort_inc(const void *a, const void *b)
{
    return (*(int*)a - *(int*)b);
}
int sort_dec(const void* a, const void* b)
{
    return (*(int*)b - *(int*)a);
}

int main()
{
	int N = 0, i = 0, prev = 0;
	int ans = 1;
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &d[i]);
	}
	qsort(d, N, sizeof(int), sort_dec);
	prev = d[0];
	for (i = 1; i < N; i++) {
		if (prev > d[i]) {
			ans++;
		}
		prev = d[i];
	}
	printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
import sys

def maxHeapify(H, A, i):
    left = 2 * i
    right = 2*i + 1

    if left <= H and A[left] > A[i]:
        largest = left
    else:
        largest = i
    if right <= H and A[right] > A[largest]:
        largest = right

    if largest != i:
        A[i], A[largest] = A[largest], A[i]
        maxHeapify(H, A, largest)

def buildMaxHeap(H, A):
    for i in range(H // 2, 0, -1):
        maxHeapify(H, A, i)

H = int(input())
A = [None] + [int(a) for a in input().split()]

buildMaxHeap(H, A)

print(' ' + ' '.join([str(a) for a in A[1:]]))

Measured memory_bytes: 66204
list = []
for i in range(5):
    list.append(int(input()))

#print(list[0])
list_2 = []
for i in range(5):
    list_2.append(list[i]%10)





list_3 = []

for i in range(5):
    list_3.append(((list[i]+ 9)//10)*10)



ans = 10
for i in range(5):
    if 0<list_2[i]<ans:
        ans = list_2[i]
print(sum(list_3)-(10-ans))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef priority_queue<long long> prque;
#define ain(i,n,a) for(long long i=0;i<(long long)(n);i++){cin>>a[i];}
#define aout(i,n,a) for(long long i=0;i<(long long)(n);i++){if(i){cout<<" ";}cout<<a[i];if(i==n-1){cout<<endl;}}
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define vsort(v) sort((v).begin(),(v).end())
#define vrsort(v) sort((v).rbegin(),(v).rend())
#define vreverse(v) reverse((v).begin(),(v).end())
#define pf(a) push_front(a)
#define pb(a) push_back(a)
#define INF 1998021900
#define MOD 1000000007
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  ll n,k,i;cin>>n>>k;vll a(n);ain(i,n,a);
  //caricurate
  vsort(a);ll sy=0;i=0;vll cn(0);
  while(i<n){
    ll cnt=0;
    while((a[i]==a[i+1])&&(i<n-1)){
      i++;cnt++;
    }
    cnt++;
    cn.pb(cnt);
    i++;
    sy++;
  }
  if(sy<=k){cout<<0<<endl;return 0;}
  vsort(cn);ll ans=0;i=0;
  for(ll j=0;j<sy-k;j++){
    ans+=cn[i];i++;
  }
  //output
  cout<<ans<<endl;
}

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
int main() {
    ios_base::sync_with_stdio(false);
    int n,w;
    cin >> n >> w;
    int wgt[n+1],val[n+1];
    for(int i=1; i<=n; i++) cin >> wgt[i] >> val[i];
    vector<LL> prev,cur;
    for(int i=0; i<=n; i++) {
        for(int j=0; j<=w; j++) {
            if(i==0 || j==0) cur.push_back(0);
            else {
                if(wgt[i]>j) cur.push_back(prev[j]);
                else cur.push_back(max(val[i]+prev[j-wgt[i]],prev[j]));
            }
        }
        prev = cur;
        cur.clear();
    }
    cout << prev[prev.size()-1] << "\n";
}


Measured memory_bytes: 1908
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

int main()
{
	int s;
	cin >> s;
	vector<int> dp(s + 1);
	dp[3] = 1;
	for (int i = 3; i <= s; i++) {
		dp[i] += dp[i - 1];
		dp[i] %= mod;
		dp[i] += dp[i - 3];
		dp[i] %= mod;
	}
	cout << dp[s] << endl;
}


Measured memory_bytes: 3632
import math
import itertools

def main():
  n = int(input())
  A = list(map(int, input().split()))
  len_A = len(A)
  times = 0

  for i in range(len_A):
    min = i
    for j in range(i+1, len_A):
      if A[j] < A[min]:
        min = j
    
    if min != i:
      tmp = A[min]
      A[min] = A[i]
      A[i] = tmp
      times += 1

  print(*A)
  print(times)

if __name__ == '__main__':
  main()


Measured memory_bytes: 5704
board=[0,0,0,0,0,0,0,0,0]
board[0],board[1],board[2] = map(int,input().split())
board[3],board[4],board[5] = map(int,input().split())
board[6],board[7],board[8] = map(int,input().split())
for _ in range(int(input())):
    x = int(input())
    if x in board:
        board[board.index(x)] = "X"
found = "No"
if board[0] == "X":
    if board[1] == "X" and board[2] == "X":
        found = "Yes"
    elif board[4] == "X" and board[8] == "X":
        found = "Yes"
    elif board[3] == "X" and board[6] == "X":
        found = "Yes"
if board[8] == "X":
    if board[5] == "X" and board[2] == "X":
        found = "Yes"
    elif board[7] == "X" and board[6] == "X":
        found = "Yes"
if board[4] == "X":
    if board[1] == "X" and board[7] == "X":
        found = "Yes"
    elif board[3] == "X" and board[5] == "X":
        found = "Yes"
    elif board[2] == "X" and board[6] == "X":
        found = "Yes"
print(found)

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

#define all(a)  (a).begin(),(a).end()
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define exist(s,e) ((s).find(e)!=(s).end())
#define pb push_back
#define range(i,a,b) for(int (i)=(a);(i)<(b);++(i))
#define rep(i,n)  range(i,0,n)
#define dump(x)  cerr << #x << " = " << (x) << endl;

using namespace std;

typedef vector<int> vi;
typedef long long ll;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int w,h;
int course[20][20];
ll dp[20][20];

int main(void){
	while(cin >> w >> h,w|h){
		clr(dp,0);
		rep(i,h)rep(j,w) cin >> course[i][j];
		rep(i,w) if(course[0][i]==0) dp[0][i]=1LL;
		rep(i,h-1)rep(j,w){
			if(course[i][j]==2&&course[i+2][j]!=1) dp[i+2][j]+=dp[i][j];
			if(course[i][j]) continue;
			for(int nj=j-1;nj<=j+1;++nj){
				if(nj<0||w<=nj) continue;
				if(course[i+1][nj]==1) continue;
				if(j!=nj&&course[i+1][nj]==2) continue;
				dp[i+1][nj]+=dp[i][j];
			}
		}
		/*
		rep(i,h+1){
			rep(j,w) cerr << dp[i][j] << " ";
			cerr << endl;
		}*/
		ll ans=0LL;
		range(i,h-1,h+1)rep(j,w) ans+=dp[i][j];
		cout << ans << endl;
	}
	return 0;
}

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

int main(){
    int S;
    int h, m, s, hRimainder;
    cin >> S;

    h=S/3600;
    hRimainder=S%3600;
    m=hRimainder/60;
    s=hRimainder%60;
    
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}


Measured memory_bytes: 3108