akhauriyash/Code-Regression huggingface dataset:
# encoding: utf-8


import sys


class Solution:
    def __init__(self):
        """
        init input array
        """
        self.__input = sys.stdin.readlines()

    @property
    def solution(self):
        length_1 = int(self.__input[0])
        array_1 = list(map(int, self.__input[1].split()))
        length_2 = int(self.__input[2])
        array_2 = list(map(int, self.__input[3].split()))

        assert length_1 == len(array_1) and length_2 == len(array_2)

        count = 0

        for each in array_2:
            if self.binary_search(key=each, array=array_1, array_length=length_1):
                count += 1

        return str(count)

    @staticmethod
    def binary_search(key, array, array_length):
        # print(len(set(array_1).intersection(set(array_2))))
        left, right = 0, array_length
        while left < right:
            mid = (left + right) // 2
            if key == array[mid]:
                return True
            elif key < array[mid]:
                right = mid
            else:
                left = mid + 1
        return False


if __name__ == '__main__':
    case = Solution()
    print(case.solution)

Measured memory_bytes: 18620
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define li long
#define pb push_back
#define mem(arr,x) memset(arr,x,sizeof(arr))

ll n,W;
ll w[101],v[101];
ll dp[101][100010];
ll totalV=0;

ll minWeight(ll end, ll Val)
{
  if(Val<=0)
  return 0;
  if(end==0)
  return INT_MAX;
  if(dp[end][Val]!=1000000010)
  return dp[end][Val];
  // if(v[end-1]>Val)
  // return dp[end][Val]=minWeight(end-1,Val);
  // else
  return dp[end][Val]=min(w[end-1]+minWeight(end-1,Val-v[end-1]), minWeight(end-1,Val));
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i,j;
    cin>>n>>W;
    for(i=0;i<n;i++)
    {
      cin>>w[i]>>v[i];
      totalV+=v[i];
    }

    for(i=0;i<=n;i++)
      for(j=0;j<=totalV;j++)
        dp[i][j]=1000000010;

    for(i=totalV;i>=1;i--)
    {
      if(minWeight(n,i)<=W)
      break;
    }
    cout<<i;
    return 0;
}

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

int main(){
	int n=0,i=0,k=0,a,b;
	int x[3000] = {0} ;

	while(1){
		cin >> n ;

		if(n <= 1000) break ;
	}

	for(i=0;i<3*n;i+=3){

		while(1){

			cin >> x[i] >> x[i+1] >> x[i+2] ;

			if((x[i] >= 1) && x[i] <=1000){
				if((x[i+1] >= 1) && x[i+1] <=1000){
					if((x[i+2] >= 1) && x[i+2] <=1000){
						break;
				}
			}
		}
		}
		if(x[i+1] > x[i]) {
			k = x[i+1];
			x[i+1] = x[i];
			x[i] = k ;
		}
		if(x[i+2] > x[i]) {
			k = x[i+2];
			x[i+2] = x[i];
			x[i] = k ;
		}
		if(x[i+2] > x[i+1]) {
			k = x[i+2];
			x[i+2] = x[i+1];
			x[i+1] = k ;
		}
	}

	for(i=0;i< 3*n; i+=3){
		a = x[i] * x[i] ;
		b = (x[i+1] * x[i+1] ) + (x[i+2] * x[i+2]) ;

		if( a == b) cout << "YES" << endl ;
		if( a != b) cout << "NO" << endl ;

	}

    return 0;
}

Measured memory_bytes: 1172
#include <iostream>
#include <cmath>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main()
{
	int n;
	cin >> n;
	double a[101],b[101];
	rep(i,n) cin >> a[i];
	rep(i,n) cin >> b[i];

	double ans;
	rep(i,3)
	{
		ans = 0;
		rep(j,n)
		{
			ans += pow(fabs(a[j]-b[j]),i+1);
		}
		ans = pow(ans,1.0/(i+1));
		cout << fixed;
		cout.precision(8);
		cout << ans << endl;
	}
	ans = 0;
	rep(i,n)
	{
		ans  = max(ans,fabs(a[i] - b[i]));
	}
	cout << fixed;
	cout.precision(8);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1344
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
using namespace std;

string o, e;

int main()
{
    cin >> o;
    cin >> e;
    int len_o = o.size(), len_e = e.size();
    int minn = min(len_o, len_e), maxn = max(len_o, len_e);
    for(int i = 0;i <= minn - 1;i++)
        cout << o[i] << e[i];
    if(len_o > len_e)
        for(int i = minn;i <= maxn - 1;i++)
            cout << o[i];
    else for(int i = minn;i <= maxn - 1;i++)
            cout << e[i];
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<pair<int,int> > bb(n);
    for(int i = 0;i < n;i++)
        cin >> bb[i].first >> bb[i].second;
    sort(bb.begin(),bb.end());
    cout << bb[bb.size()-1].first  + abs(bb[bb.size()-1].second - 0);
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<string>
#include<string.h>
#include<memory.h>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<sstream>
#include<cmath>
#include<list>
#include<deque>
#include<stack>
#include<ctime>
using namespace std;         //一遍dfs，利用nreach,son计算点的个数
vector<int> q;
vector<int> r[100100];
int son[100100];
int nreach,n;
int dfs(int a,int fa)
{q.push_back(a);
son[a]=1;
if(a==n) {nreach=q[(q.size()+1)/2];}
for(int i=0;i<r[a].size();i++)
								{int nex=r[a][i];
								if(nex==fa) continue;
								son[a]+=dfs(nex,a);
								}
q.pop_back();
return son[a];
}
int main()
{cin>>n;
int a,b;
for(int i=0;i<n-1;i++)
{cin>>a>>b;
r[a].push_back(b);
r[b].push_back(a);
}
int _=dfs(1,-1);
if(son[nreach]<son[1]-son[nreach])  cout<<"Fennec";
else cout<<"Snuke";
return 0;
}


Measured memory_bytes: 11256
#include <bits/stdc++.h>
using namespace std;
//static const int INF = (1 << 21);
typedef long long ll;
int main(void){
    // Your code here!
    vector<int> A(5);
    for(int i = 0; i < 5; i++){
        cin >> A.at(i);
    }
    int k;
    cin >> k;
    sort(A.begin(),A.end());
    if(A.at(4) - A.at(0) > k){
        cout << ":(" << endl;
    }
    else{
        cout << "Yay!" << endl;
    }
}

Measured memory_bytes: 256
import sys
def I(): return int(sys.stdin.readline().rstrip())

K = I()
q,r = K//50,K % 50
A = [49+q-i for i in range(50)]
B = [50+q-i for i in range(50)]
C = A[r:] + B[:r]

print(50)
print(*C)


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

int main() {
  int n, ans = 0;

  cin >> n;

  vector<int> a(n);

  for (int i = 0; i < n; i++) cin >> a[i];

  for (int i = 1; i < n - 1; i++)
    if ((a[i] < a[i + 1] && a[i] > a[i - 1]) ||
        (a[i] > a[i + 1] && a[i] < a[i - 1]))
      ans++;

  cout << ans;

  return 0;
}

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

using namespace std;

const int N = 101;
int X,Y;
int mat[N][N];
bool used[N];
int girls[N];

void add(int x,int y){
    mat[x][y] = 1;
}

int dfs(int v){
    used[v] = true;
    for(int i=0;i<Y;i++){
        if(!mat[v][i]) continue;
        int u = girls[i];
        if(u==-1 || !used[u] && dfs(girls[i])){
            girls[i] = v;
            return 1;
        }
    }
    return 0;
}

int match(){
    int ans = 0;
    memset(girls,-1,sizeof(girls));
    for(int i=0;i<X;i++){
        memset(used,0,sizeof(used));
        ans += dfs(i);
    }
    return ans;
}

int main(){
    int E;
    cin>>X>>Y>>E;
    memset(mat,0,sizeof(mat));
    for(int i=0;i<E;i++){
        int x,y;
        cin>>x>>y;
        add(x,y);
    }

    cout<<match()<<endl;

    return 0;
}


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

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

const ll INF = 1LL << 60;

int main(){
  int n,k;
  cin >> n >> k;
  int a[1000000];
  FOR(i,n){
    cin >> a[i];
    if(a[i]==1){
      int c=i;
    }
  }
int ans=0,v=n-k;
  FOR(i,n){
    if(v<=0){break;}
    v-=(k-1);
    ans++;
  }

  cout << ans+1 << endl;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using vl = vector<long long>;
#define INF (lint)3e18
#define P pair<lint,lint>
lint n, k;
vl a;
vl f;
P e;//開けた箱のカウント
bool h = true;//出力用

bool solve(vl& r) {//判定用・trueだったら参照渡しのrに格納した情報を出力
	e.first = INF;//e.firstは,「前回宝のあった場所」
	for (int i = 0; i <= k; i++) {//K+1回or-になって終わるまでループし続ける
		lint s = INF;//large
		e.second = -INF;//前回宝のあった場所以外で一番残り開けられる回数の少ない箇所
		for (int j = 0; j < n; j++) {
			if (j != e.first && s >= a[j]) {//宝の開けられる回数の最小値をe.secondに記録
				e.second = j;
				s = a[j];
			}
		}
		for (int j = 0; j < n; j++) {
			if (j != e.first && j != e.second) {//まず開くものだけ
				r.push_back(j + (lint)1);//開く順番を参照渡しした配列に記録
				a[j]--;//e.firstとe.second以外の要素は-1する
				if (a[j] < 0) { //0未満になっていたら強制的に飛ぶ
					h = false;
					goto ywr;//飛ぶ
				}
			}
		}
		e.first = e.second;//その後e.secondを開ける
		e.second++;
		r.push_back(e.second);
		e.second--;
		a[e.second]--;
		if (a[e.second] < 0) {//判定
			h = false;
			goto ywyw;//飛ぶ
		}
	}

ywr:;
ywyw:;//飛ぶ
	return h;//gotoされていない限りはture
}

int main(void) {
	cin >> n >> k;
	a.resize(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];//入力
	/**/
	if (!solve(f)) //これで必勝法があるかどうかの判定
		printf("%d", -1);//無ければ-1
	else {
		printf("%zd\n", f.size());//必勝法のサイズ
		for (int i = 0; i < f.size(); i++) {
			if (i != f.size() - 1) //出力
				cout << f[i] << ' ';
			else
				cout << f[i];
		}
	}
	printf("\n");//どちらのパターンもここで改行する

	return 0;
}

Measured memory_bytes: 3776
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long int;
using ULL = unsigned long long;

int main() {
    int a, b;
    cin >> a >> b;
    if (a > b) {
        if (a - 1 > b) {
            cout << a + a - 1 << endl;
        } else {
            cout << a + b << endl;
        }
    } else {
        if (b - 1 > a) {
            cout << b + b - 1 << endl;
        } else {
            cout << b + a << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <math.h> // sqrt()
#include <iomanip>

using namespace std;

int main(){
    string s;
    cin >> s;
    int one , zero;
    one = 0;
    zero = 0;
    for (char i :s){
        if( i == '1') one++;
        else zero++;
    }
    cout << 2 * min(one , zero) << endl;
    
}


Measured memory_bytes: 3720
#include<stdio.h>
int main(void)
{
	int a,b,c,i,cnt=0;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++){
		if(c%i==0){
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}

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

bool cmp(const pair<int,int> &a, const pair<int,int> &b)
{
    return a.first > b.first;
}

int main() {
  int n,m;
  cin >> n >> m;
  vector<pair<int,int>> W;
  rep(i,n){
    int a,b;
    cin >> a >> b;
    pair<int,int> c = make_pair(a,b);
    W.push_back(c);
  }
  sort(W.begin(),W.end(),cmp);
  int money = 0;
  priority_queue<int> Q;
  for(int day=1; day<=m; day++){
    while(W.back().first == day && W.size() > 0){
      Q.push(W.back().second);
      W.pop_back();
    }
    if (Q.size() > 0){
      money += Q.top();
      Q.pop();
    }
  }
  cout << money << endl;

  return 0;
}


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

using namespace std;

int main(){
	int n;
	cin >> n;
	int taroScore = 0, hanakoScore = 0;
	string taroCard, hanakoCard;
	for(int i = 0; i < n; i++){
		cin >> taroCard >> hanakoCard;
		if(taroCard > hanakoCard){
			taroScore += 3;
		}
		else if(taroCard < hanakoCard){
			hanakoScore += 3;
		}
		else{
			taroScore++; hanakoScore++;
		}
	}
	cout << taroScore << " " << hanakoScore << endl;

	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using Int = uint64_t;
static const Int MOD = 1e9 + 7;
Int solve() {
    Int N, ans = 1;
    cin >> N;
    vector<vector<Int>> x(N + 1, vector<Int>(3, 0));
    for(int i = 0, A; i < N; i++) {
        cin >> A;
        ans = (ans * count(x[i].begin(), x[i].end(), A)) % MOD;
        if (ans == 0) return ans;
        auto itr = find(x[i].begin(), x[i].end(), A);
        x[i + 1] = x[i];
        x[i + 1][distance(x[i].begin(), itr)]++;
    }
    return ans;
}
int main() {
    cout << solve() << endl;
}


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

//unsigned long long
int main()
{
    int N, K;
    string S;
    cin >> N;
    cin >> K;
    cin >> S;
    S[K - 1] = S[K - 1] - ('A' - 'a');
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
char a[100][100];

int main()
{
    int r,c,n=0,f=0;
    cin>>r>>c;
    /*for(int i=0;i<=r+2;i++)
    {
        for(int j=0;j<=c+2;j++)
        {
            a[i][j]='.';
        }
    }*/

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

    for(int i=1;i<=r;i++)
    {
        for(int j=1;j<=c;j++)
        {
            if(a[i][j]=='#') {
                if(a[i-1][j]=='.'&&a[i+1][j]=='.'&&a[i][j-1]=='.'&&a[i][j+1]=='.'){
                cout<<"No\n";
                return 0;
                }
            }
        }
    }

    cout<<"Yes\n";
    return 0;
}


Measured memory_bytes: 256
N, K= map(int, input().split())
h = list(map(int, input().split()))
dp = [0]*(N+1)
for i in range(1, N):
    dp[i+1] = min(
        [
            abs(h[i]-h[i-k]) + dp[i+1-k]
            for k in range(1, min(K, i)+1)
        ]
    )
print(dp[N])

Measured memory_bytes: 52448
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k=int(input())
print(a[k-1])

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<cmath>
#include<ctype.h>
#include<vector>
#include<cstdlib>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<stack>
#include<map>

#define ll long long
#define LL long long
#define ULL unsigned long long 
#define ull unsigned long long 
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)

using namespace std;
int N;


int ball[11];


bool solve(int i,int tmp_1,int tmp_2) {
	if (tmp_1 < ball[i] && tmp_2 < ball[i]) 
		return max(solve(i + 1, ball[i], tmp_2), solve(i + 1, tmp_1, ball[i]));
	
	if (tmp_1 < ball[i] && tmp_2 >= ball[i]) 
		return solve(i + 1, ball[i], tmp_2);
	
	if (tmp_1 >= ball[i] && tmp_2 < ball[i]) 
		return solve(i + 1, tmp_1, ball[i]);
	
	if (i == 10) 
		return true;
	
	if (tmp_1 >= ball[i] && tmp_2 >= ball[i]) 
		return false;
	

}

int main()
{
	int tmp[2] = {};
	cin >> N;
	REP(i, N) {
		REP(j, 10) {
			cin >> ball[j];
		}
		if (solve(0, 0, 0)) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}

	}

	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
using namespace std;
int main()
{
	int N, M, i;
	cin >> N;
	int a[N];
	for (i = 0; i < N; i++) cin >> a[i];
	cin >> M;
	int b[M];
	for (i = 0; i < M; i++) cin >> b[i];
	i = 0;
	while (i < N&&i < M) {
		if (a[i] == b[i]) { i++; continue; }
		else if (a[i] < b[i]) { cout << 1 << endl; return 0; }
		else { cout << 0 << endl; return 0; }
	}
	if (M > N)cout << 1 << endl;
	else
		cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 3108
#include<stdio.h>

int parent(int i){
    return i/2;
}
int left(int i){
    return i*2;
}
int right(int i){
    return i*2+1;
}

int main(){

    int n;
    scanf("%d", &n);

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

    for(int i=1; i<=n; i++){
        printf("node %d: key = %d, ", i, A[i]);
        if(parent(i)>=1) printf("parent key = %d, ", A[parent(i)]);
        if(left(i)<=n) printf("left key = %d, ", A[left(i)]);
        if(right(i)<=n) printf("right key = %d, ", A[right(i)]); 
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2760
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N;
  cin >> N;
  int b[100000];
  for (int i=0; i<N-1; i++){
    cin >> b[i];
  }

  long long sum = 0;
  int old;
  for (int i=0; i<N; i++){
    if (i == 0) {
      sum = sum + b[0];
      old = b[0];
    }
    // else if (i == 1) {
    //   sum = sum + b[0];
    //   old = b[0];
    // }
    else if (i == N-1) {
      // sum = sum + min(b[N-2], old);
      // old = min(b[N-2], old);
      sum = sum + b[N-2];
    }
    else {
      int temp = min(b[i-1], b[i]);
      sum = sum + temp;
      old = temp;
    }
  }

  cout << sum << endl;

  return 0;
}


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



int main(){
	
	int N,K,R,S,P;
	cin>>N>>K>>R>>S>>P;
	
	string T;
	cin>>T;
	
	int rr = 0,ss = 1,pp = 2;
	
	int ans = 0;
	for(int i=0;i<K;i++){
		string s = "";
		for(int j=i;j<T.size();j+=K){
			s += T[j];
		}
		vector<vector<int>> dp(s.size(),vector<int>(3,0));
		for(int j=0;j<s.size();j++){
			for(int k=0;k<3;k++){
				if(j==0){
					dp[j][k] = 0;
					if(k==rr&&s[j]=='s')dp[j][k] = R;
					if(k==ss&&s[j]=='p')dp[j][k] = S;
					if(k==pp&&s[j]=='r')dp[j][k] = P;
				}
				else{
					for(int p=0;p<3;p++){
						if(k==p)continue;
						dp[j][k] = max(dp[j][k],dp[j-1][p]);
					}
					if(k==rr&&s[j]=='s')dp[j][k] += R;
					if(k==ss&&s[j]=='p')dp[j][k] += S;
					if(k==pp&&s[j]=='r')dp[j][k] += P;
				}
			}
		}
		ans += max({dp.back()[0],dp.back()[1],dp.back()[2]});
	}
	
	cout<<ans<<endl;
	
    return 0;
}


Measured memory_bytes: 6016
#include<stdio.h>

int solve(int, int);

int a[3000];
int n;

int main(){
  int q;
  int m[3000];
  int i;
  int c;

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

  scanf("%d",&q);
  for(i=0; i< q; i++){
    scanf("%d",&m[i]);
  }

  for(i=0; i < q; i++){

    if(solve(0,m[i])==1){
      printf("yes\n");
    }
      else{
	printf("no\n");
      }
  }

  return 0;
}


int solve(int i, int m){

  int res;
  if(m==0) return 1;
  if(i >= n) return 0;

  res=solve(i+1,m) || solve(i+1,m-a[i]);
  return res;
}

Measured memory_bytes: 588
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin >> n;
    if(n % 2 == 1)
    {
        cout << 0;
    }
    else
    {
        long long cnt = 10,ans = 0;
        while (n >= cnt)
        {
            ans += n / cnt;
            cnt *= 5;
        }
        cout << ans;
    }
    
}


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

int main(void){
   int S,h,m,s;
   cin >> S;
   h=S/3600;
   m=(S%3600)/60;
   s=(S%3600)%60;
   cout << h;
   cout << ":";
   cout << m;
   cout << ":";
   cout << s;
   cout << endl;
}


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

#define ll long long

int main()
{
  ll a,b,c;
  cin >> a >> b >> c;
  if(a&1 && b&1 && c&1)
    cout << min({a*b,b*c,c*a});
  else
    cout << 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef  long long LL;
typedef  unsigned long long ULL;
typedef  double db;
typedef  long double ld;
#pragma comment(linker, "/STACK:102400000,102400000")
#define fuck(x) cout<<x<<endl
#define fuck1(x,y) cout<<x<<" "<<y<<endl
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define MP(a,b) make_pair(a,b)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
const int INF = 0x3f3f3f3f3f,mod = 1e9+7;
const double eps  =1e-6,PI = acos(-1);
template<typename T> inline void read(T &x){
    x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}
const int maxn = 1e5+100;
int N,K;
int ax[505],pre[505],suf[505];
int dp1[505],dp2[505];
vector<int> ac;
struct node{
    int v,d1;
}bx[505];
bool comp(node A,node B){
     return A.d1<B.d1;
}
int main(){
    read(N),read(K);
    int sum = 0;
    for(int i = 1;i<=N;i++)read(ax[i]),sum+=ax[i];
    sort(ax+1,ax+1+N);
    for(int i = 1;i<=sqrt(sum);i++){
        if(sum%i==0){
            int temp = sum/i;
            if(temp!=i)ac.push_back(i),ac.push_back(temp);
            else ac.push_back(i);
        }
    }
    for(int i = 1;i<=N;i++)pre[i] = pre[i-1]+ax[i];
    for(int i = N;i>=1;i--)suf[i] = suf[i+1]+ax[i];
    sort(ac.begin(),ac.end());
    for(int i = ac.size()-1;i>=0;i--){
        int temp = ac[i];
        int num = sum/temp;
        int tot = 0,tot1 = 0,tempnum = num;
        for(int i = 1;i<=N;i++){
            int k = ax[i]/temp;
            bx[i].v = ax[i];
            dp1[i] = ax[i] - k*temp;
            dp2[i] = (k+1)*temp - ax[i];
            bx[i].d1 = dp1[i];
        }
        sort(bx+1,bx+1+N,comp);
        suf[N+1] = 0;
        for(int i = N;i>=1;i--){
            int k = bx[i].v/temp;
            dp1[i] = ax[i] - k*temp;
            dp2[i] = (k+1)*temp - bx[i].v;
            suf[i] = suf[i+1] +dp2[i];
        }
        int sum = 0,flag = 0;
        for(int i = 1;i<=N;i++){
            sum+=bx[i].d1;
            //fuck1(sum,suf[i+1]);
            if(sum==suf[i+1]&&sum<=K){
                flag = 1;
                break;
            }
        }
        if(flag){
            printf("%d\n",temp);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int ans = 0, low = 2e5, p;
    for(int i = 0; i < n; i++){
        cin >> p;
        low = min(low, p);
        if(low == p) ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node{
  int p, l, r;
};

struct Node T[MAX];
int n;

void preParse(int u){
  if ( u == NIL ) return;
  printf(" %d", u);
  preParse(T[u].l);
  preParse(T[u].r);
}
void inParse(int u){
  if ( u == NIL ) return;
  inParse(T[u].l);
  printf(" %d", u);
  inParse(T[u].r);
}
void postParse(int u){
  if ( u == NIL ) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d", u);
}

main(){
  int i, v, l, r, root;
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) {
    T[i].p = NIL;
  }

  for ( i = 0; i < n; i++ ){
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if ( l != NIL ) T[l].p = v;
    if ( r != NIL ) T[r].p = v;
  }

  for ( i = 0; i < n; i++ ) if ( T[i].p == NIL ) root = i;
  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}


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

int main() {
  string A,B;
  cin>>A>>B;
  int sizeA=A.size();
  int sizeB=B.size();
  
  int mincount=1000;
  int sa=sizeA-sizeB;
  //cout<<sa<<endl;
  for(int p=0;p<=sa;p++){
    int count=0;
    for(int k=0;k<sizeB;k++){
      if(A.at(p+k)==B.at(k)){
        count++;
      }
    }
    if(mincount>sizeB-count){
      mincount=sizeB-count;
    }
  }
  cout<<mincount;
}

  


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include<iostream>
#define Ganesha ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define lli long long int
using namespace std;
bool isPrime(lli n){
	if(n==1) return false;
	if(n==2||n==3||n==5) return true;
	if(n%2==0||n%3==0||n%5==0) return false;
	for(lli i=5;i*i<=n;i+=6){
		if(n%i==0||n%(i+2)==0) return false;
	}
	return true;
}
int main(){
    Ganesha
    bitset<4000001> S;
    int s=0,rs=0,i,n,x;
    S[0]=true;
    cin>>n;
    for(int i=0;i<n;i++){
    	cin>>x;
    	s+=x;
    	S=S|(S<<x);
    }
    rs=(s+1)/2;
    for(i=rs;i<=s;i++){
    	if(S[i]) break;
    }
    cout<<i<<endl;
    return 0;

}

Measured memory_bytes: 2176
using System;
public class test
{
    public static void Main()
    {
        int n=int.Parse(Console.ReadLine());
        string[] s = Console.ReadLine().Trim().Split(' ');
        int sum = 0;
        for (int i = 0; i < n-1; i++)
        {
            for(int i2 = i + 1; i2 < n; i2++)
            {
                sum += int.Parse(s[i]) * int.Parse(s[i2]);
            }
        }
        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
    int n; cin>>n;
    int a[n+1]; rep(i,n+1) a[i]=1;
    rep(i,n+1){
        int tmp=i,j=2;
        while(tmp>1){
            if(tmp%j==0){
                tmp/=j;
                a[j]++;
            }else{
                j++;
            }
        }
    }
    long ans=1;
    rep(i,n+1) ans=ans*a[i]%1000000007;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys

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


def main():
    N, M, *AB = map(int, read().split())
    G = [[] for _ in range(N)]
    for a, b in zip(*[iter(AB)] * 2):
        G[a - 1].append(b - 1)

    def dfs(v, p, seen, finished, hist):
        seen[v] = True
        hist.append(v)
        for nv in G[v]:
            if nv == p:
                continue
            if finished[nv]:
                continue
            if seen[nv] and not finished[nv]:
                return nv

            pos = dfs(nv, v, seen, finished, hist)
            if pos != -1:
                return pos
        hist.pop()
        finished[v] = True
        return -1

    for i in range(N):
        seen = [False] * N
        finished = [False] * N
        hist = []
        pos = dfs(i, -1, seen, finished, hist)
        if pos != -1:
            break

    if pos == -1:
        print(-1)
        return

    cycle = []
    while hist:
        t = hist.pop()
        cycle.append(t)
        if t == pos:
            break

    cycle.reverse()

    while True:
        order = [-1] * N
        for i, v in enumerate(cycle):
            order[v] = i

        for i, v in enumerate(cycle):
            ord_from = ord_to = -1
            for nv in G[v]:
                if v == nv or order[nv] == -1 or order[nv] == (order[v] + 1) % len(cycle):
                    continue
                ord_from, ord_to = i, order[nv]
                break
            if ord_from != -1:
                break

        if ord_from == -1:
            break

        if ord_from < ord_to:
            cycle = cycle[: ord_from + 1] + cycle[ord_to:]
        else:
            cycle = cycle[ord_to : ord_from + 1]

    print(len(cycle))
    for v in cycle:
        print(v + 1)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 10284
#include <cstdio>


int N;
char S[4010];

typedef long long int ll;

ll C(int n,int m){
    if (m>n) return 0;

    ll a=1,b=1;
    for(int i=0;i<m;i++){
        a*=(n-i);
        b*=(i+1);
    }

    return a/b;
}

int main(){
    scanf("%d",&N);
    scanf("%s",S);
    int R=0,G=0,B=0;//count

    for(int i=0;i<N;i++) 
        switch (S[i])
        {
        case 'R':
            R++;
            break;
        case 'G':
            G++;
            break;
        case 'B':
            B++;
            break;
        default:
            return -1;
        }

    ll total=C(N,3),reverse=0;
    reverse+=C(R,3);
    reverse+=(C(R,2)*(N-R));
    reverse+=C(G,3);
    reverse+=(C(G,2)*(N-G));
    reverse+=C(B,3);
    reverse+=(C(B,2)*(N-B));

    // printf("%lld\n",reverse);

    for(int i=1;i<=N;i++){
        for(int s=0;s<=N;s++){
            if (s+i+i>=N) break;
            if (S[s]==S[s+i]) continue;
            if (S[s+i]==S[s+i+i]) continue;
            if (S[s]==S[s+i+i]) continue;
            // printf("s=%d i=%d\n",s,i);
            reverse++;
        }
    }

    printf("%lld\n",total-reverse);

    return 0;
}

Measured memory_bytes: 1736
#pragma GCC optimize("-Ofast")

#include <bits/stdc++.h>

using namespace std;

signed main(){
    /* 入力の受け取り */
    int h,w;
    cin >> h >> w;
    int** a = new int*[h];
    for (int i = 0;i < h;++i)
        a[i] = new int[w];
    for (int i = 0;i < h;++i)
        for (int j = 0;j < w;++j)
            cin >> a[i][j];

    int ans = 0; // 答えの操作回数
    string ans_s = ""; // 答えの操作

    /*
        各i=0,1,...,h-1について、
            a[i][0] -> a[i][1] -> ... -> a[i][w-1]
        とコインを動かし、a[i][w-1]以外を偶数にする.
    */
    for (int i = 0;i < h;++i){
        for (int j = 0;j < w - 1;++j){
            if (a[i][j] & 1){ // a[i][j]が奇数ならa[i][j+1]に1枚移動
                --a[i][j];
                ++a[i][j + 1];
                ++ans;
                ans_s += to_string(i + 1) + " ";
                ans_s += to_string(j + 1) + " ";
                ans_s += to_string(i + 1) + " ";
                ans_s += to_string(j + 2) + "\n";
            }
        }
    }

    /*
        各i=0,1,...,h-2について、a[i][w-1]が奇数ならa[i+1][w-1]に1枚移動
     */
     for (int i = 0;i < h - 1;++i){
         if (a[i][w - 1] & 1){
             --a[i][w - 1];
             ++a[i + 1][w - 1];
             ++ans;
             ans_s += to_string(i + 1) + " ";
             ans_s += to_string(w) + " ";
             ans_s += to_string(i + 2) + " ";
             ans_s += to_string(w) + "\n";
         }
     }

    cout << ans << endl;
    cout << ans_s;

    /* メモリの開放 */
    for (int i = 0;i < h;++i)
        delete[] a[i];
    delete[] a;

    return 0;
}

Measured memory_bytes: 5124
#include <iostream>
  #include <string>
  #include <vector>
  #include <algorithm>
  #include <utility>
  #include <numeric>
  #include <map>
  using namespace std;
  typedef long long ll;
  #define rep(i,n) for (int i=0;i < (int)(n);i++)
  
  int main(){
   int sx,sy,gx,gy;
   int vecx,vecy;
   cin >> sx >> sy >> gx >> gy;
   vecx=gx-sx;
   vecy=gy-sy;
   if (vecx >= 0){
     rep(i,abs(vecx)) cout << 'R';
   }
   else{
     rep(i,abs(vecx)) cout << 'L';
   }
   if (vecy >= 0){
     rep(i,abs(vecy)) cout << 'U';
   }
   else{
     rep(i,abs(vecy)) cout << 'D';
   }
   //first online
   if (vecx >= 0){
     rep(i,abs(vecx)) cout << 'L';
   }
   else{
     rep(i,abs(vecx)) cout << 'R';
   }
   if (vecy >= 0){
     rep(i,abs(vecy)) cout << 'D';
   }
   else{
     rep(i,abs(vecy)) cout << 'U';
   }
   //second online
   if (vecy >= 0) cout << 'D';
   else cout << 'U';
  // two 
  if (vecx >= 0){
     rep(i,abs(vecx)+1) cout << 'R';
   }
   else{
     rep(i,abs(vecx)+1) cout << 'L';
   }
   if (vecy >= 0){
     rep(i,abs(vecy)+1) cout << 'U';
   }
   else{
     rep(i,abs(vecy)+1) cout << 'D';
   }
   // clear
   if (vecx >= 0) cout << 'L';
   else cout << 'R';
   //two second
   if (vecy >= 0) cout << 'U';
   else cout << 'D';
   // return 
   if (vecx >= 0){
     rep(i,abs(vecx)+1) cout << 'L';
   }
   else{
     rep(i,abs(vecx)+1) cout << 'R';
   }
   if (vecy >= 0){
     rep(i,abs(vecy)+1) cout << 'D';
   }
   else{
     rep(i,abs(vecy)+1) cout << 'U';
   }
   // modfin
   if (vecx >= 0) cout << 'R';
   else cout << 'L';

   cout << endl;   
    return 0;
  }

//RUULDDDRUUULDD

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)n;i++)
#define ll long long
#define BIT_FLAG_0 (1<<0) // 0000 0000 0000 0001
#define BIT_FLAG_1 (1<<1) // 0000 0000 0000 0010
#define BIT_FLAG_2 (1<<2) // 0000 0000 0000 0100
#define BIT_FLAG_3 (1<<3) // 0000 0000 0000 1000
#define BIT_FLAG_4 (1<<4) // 0000 0000 0001 0000
#define BIT_FLAG_5 (1<<5) // 0000 0000 0010 0000
#define BIT_FLAG_6 (1<<6) // 0000 0000 0100 0000
#define BIT_FLAG_7 (1<<7) // 0000 0000 1000 0000

int main(){
    int n,m;
    int h[100001],aa[100001];
    cin >> n >> m;

    rep(i,n){
        cin >> h[i];
        aa[i]=0;
    }
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        aa[a]=max(aa[a],h[b]);
        aa[b]=max(aa[b],h[a]);
    }
    int ans=0;
    rep(i,n)
        ans+=h[i]>aa[i];
    cout << ans << endl;
}

Measured memory_bytes: 4344
#include<iostream>
#include<string>
using namespace std;
int main() {
  string str;
  cin >> str;
  int n;
  cin >> n;
  for(int i = 0 ; i < n ; i++ ){
    string op;
    cin >> op;

    if(op == "replace") {

        int a, b;
        string repstr;
        cin >> a >> b >> repstr;
        auto it = str.begin() + a;
        for (int j = 0; j <= b-a; j++){
          *it++ = repstr[j];
        }

    } else if (op == "reverse") {

        int a, b;
        cin >> a >> b;
        string str2 = str;
        auto it = str.begin() + a;
        auto it2 = str2.begin() + b;
        for (int j = 0; j <= b-a; j ++) {
          *it++ = *it2--;
        }


    } else if (op == "print") {
        int a, b;
        cin >> a >> b;
        auto it = str.begin() + a;
        for (int j = 0; j <= b-a; j++){
          cout <<  *it++;
        }
        cout << endl;

    }
  }

}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200200;
const double pi = acos(-1);
int fenw[maxn];
void add(int x, int v){
	for(x++; x < maxn; x += x & - x) fenw[x] = max(fenw[x], v);
}
int sum(int x){
	int ans = 0;
	for(x++; x; x -= x & - x) ans = max(ans, fenw[x]);
	return ans;
}
long long x[maxn], y[maxn];
int main(){
	cout << fixed << setprecision(15);
	long long sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	int n; cin >> n;
	for(int i = 0; i < n; i++) cin >> x[i] >> y[i];
	if(sx == tx){
		int cnt = 0;
		for(int i = 0; i < n; i++) if(sx == x[i] && min(sy, ty) <= y[i] && y[i] <= max(sy, ty)) cnt++;
		if(cnt) cout << abs(sy - ty) * 100 - 20 + 10 * pi << endl;
		else cout << abs(sy - ty) * 100 << endl;
	} else if(sy == ty){
		int cnt = 0;
		for(int i = 0; i < n; i++) if(sy == y[i] && min(sx, tx) <= x[i] && x[i] <= max(sx, tx)) cnt++;
		if(cnt) cout << abs(sx - tx) * 100 - 20 + 10 * pi << endl;
		else cout << abs(sx - tx) * 100 << endl;
	} else {
		tx -= sx; ty -= sy;
		for(int i = 0; i < n; i++) x[i] -= sx, y[i] -= sy;
		if(tx < 0){
			tx *= -1;
			for(int i = 0; i < n; i++) x[i] *= -1;
		}
		if(ty < 0){
			ty *= -1;
			for(int i = 0; i < n; i++) y[i] *= -1;
		}
		vector<pair<int,int> > p;
		for(int i = 0; i < n; i++) if(x[i] >= 0 && y[i] >= 0 && x[i] <= tx && y[i] <= ty) p.push_back({x[i], y[i]});
		sort(p.begin(), p.end());
		vector<int> ys;
		for(auto e : p) ys.push_back(e.second);
		sort(ys.begin(), ys.end());
		ys.erase(unique(ys.begin(), ys.end()), ys.end());
		int fnt = 0;
		for(auto e : p){
			int x, y; tie(x, y) = e;
			int ny = lower_bound(ys.begin(), ys.end(), y) - ys.begin();
			int best = sum(ny);
			add(ny, best + 1);
			fnt = max(fnt, best + 1);
		}
		if(fnt == min(tx, ty) + 1) 
			cout << (tx + ty) * 100 - fnt * 20 + fnt * 5 * pi + 5*pi << endl;
		else
			cout << (tx + ty) * 100 - fnt * 20 + fnt * 5 * pi << endl;
	}
	return 0;
}



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

int main(){
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if(s<t)cout<<"Yes"<<endl;
    else cout << "No" << endl;
}

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

int main() {
  int N,Y;
  cin >> N >> Y;
  int finished = 0;
  for(int i=0;i<=N;i++) {
    for(int j=0;j<=N-i;j++) {
      if(10000*i+5000*j+1000*(N-i-j) == Y) {
        finished=1;
        cout << i << ' ' << j << ' ' << 
          N-i-j << endl;
        break;
      }
    }
    if(finished == 1) {
      break;
    }
  }
  if(finished == 0) {
    cout << "-1 -1 -1" << endl;
  }
}




Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
module Main where

easyOdd :: String -> Bool
easyOdd []      = True
easyOdd ('R':s) = easyEven s
easyOdd ('U':s) = easyEven s
easyOdd ('D':s) = easyEven s
easyOdd _       = False

easyEven :: String -> Bool
easyEven []      = True
easyEven ('L':s) = easyOdd s
easyEven ('U':s) = easyOdd s
easyEven ('D':s) = easyOdd s
easyEven _       = False

main :: IO ()
main = do
  !s <- getLine
  putStrLn $ if easyOdd s then "Yes" else "No"


Measured memory_bytes: 380
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


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

    int a, b, c;
    cin >> a >> b >> c;
    {
        int mn = min(a, min(b, c));
        a -= mn;
        b -= mn;
        c -= mn;
    }

    int N = 80;
    const int INF = 1 << 24;
    vector<vector<vector<int>>> dp(N + 1, vector<vector<int>>(N + 1, vector<int>(N + 1, INF)));
    dp[a][b][c] = 0;

    auto update = [&](int a, int b, int c, int val) {
        if (a >= 0 && a <= N && b >= 0 && b <= N && c >= 0 && c <= N) {
            dp[a][b][c] = min(dp[a][b][c], val);
        }
    };

    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j <= N; ++j) {
            for (int k = 0; k <= N; ++k) {
                if (dp[i][j][k] >= INF) {
                    continue;
                }
                vector<int> pos{i, j, k};
                for (int l = 0; l < 3; ++l) {
                    pos[l] += 2;
                    update(pos[0], pos[1], pos[2], dp[i][j][k] + 1);
                    pos[l] -= 2;

                    for (int x = 0; x < 3; ++x) {
                        if (x != l) {
                            pos[x] += 1;
                        }
                    }
                    update(pos[0], pos[1], pos[2], dp[i][j][k] + 1);
                    for (int x = 0; x < 3; ++x) {
                        if (x != l) {
                            pos[x] -= 1;
                        }
                    }
                }
            }
        }
    }

    int res = INF;
    for (int i = 0; i <= N; ++i) {
        res = min(dp[i][i][i], res);
    }

    cout << res << '\n';


    return 0;
}

Measured memory_bytes: 2560
# coding:utf-8
H, W = list(map(int, input().split()))
s = []
ans = []
for i in range(H):
    s.append(input())
    ans.append([])
for i in range(H):
    for j in range(W):
        if(s[i][j] == "#"):
            ans[i].append("#")
            continue
        ans[i].append(0)

for i in range(H):
	for j in range(W):
		if s[i][j] == '#':
			for h in range(-1,2):
				for k in range(-1,2):
					if h == 0 and k == 0:
						continue
					if (i == 0 and h == -1) or (i == H -1 and h == 1) or (j == 0 and k == -1) or (j == W-1 and k == 1):
						continue

					if (s[i+h][j+k]) != '#':
 						ans[i+h][j+k] += 1  
			ans[i][j] = '#'

o = ""
for i in range(H):
	for j in range(W):
		o += str(ans[i][j])
	o += "\n"
print (o)

Measured memory_bytes: 3064
x=int(input())

for i in range(100):
  for j in range(i):
    if i**5+j**5==x:
      print(i,-j)
      exit()
for i in range(500):
  for j in range(i):
    if i**5 -j**5==x:
      print(i,j)
      exit()

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

template<long long mod>
class modint{
private:
  long long a;
public:
  constexpr modint(const long long x = 0) noexcept : a(x%mod) {}
  constexpr long long& value() noexcept { return a; }
  constexpr const long long& value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint& operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if(a >= mod) a -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if(a < rhs.a) a += mod;
    a -= rhs.a;
    return *this;
  }
  constexpr modint& operator*=(const modint rhs) noexcept {
    a = a*rhs.a%mod;
    return *this;
  }
  constexpr modint& operator/=(modint rhs) noexcept {
    long long k = mod-2;
    while(k > 0){
      if(k&1){
        *this *= rhs;
      }
      rhs *= rhs;
      k /= 2;
    }
    return *this;
  }
  friend ostream& operator<<(ostream &os, const modint &X){
    return os << X.a;
  }
  friend istream& operator>>(istream &is, modint &X){
    is >> X.a;
    X.a %= mod;
    if(X.a < 0) X.a += mod;
    return is;
  }
};

template<typename T>
T power(T x, long long k){
  T ret{1};
  while(k > 0){
    if(k&1) ret *= x;
    x *= x;
    k /= 2;
  }
  return ret;
}

int main(){
  long long n, a , b;
  cin >> n >> a >> b;
  using mint = modint<(int)1e9+7>;
  mint ans = power<mint>(2,n)-1;
  auto comb = [](long long n, long long k){
                mint ret = 1;
                for(int i = 0; i < k; ++i)
                  ret *= n-i;
                for(int i = 1; i <= k; ++i)
                  ret /= i;
                return ret;
              };
  ans -= comb(n,a)+comb(n,b);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N, Y;
    cin>>N>>Y;
    for (int x = 0; x <= N; x++)
    {
        for (int y = 0; x + y <= N; y++)
        {
            int z = N - (x + y);
            if (10000*x + 5000*y + 1000*z == Y)
            {
                cout<<x<<" "<<y<<" "<<z;
                return 0;
            }
        }
    }

    puts("-1 -1 -1");

    return 0;
}



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

int main(){
  string s;
  cin >> s;
  sort(s.begin(),s.end());
  if(s[0]==s[1] && s[2]==s[3] && s[1]!=s[2]){
    cout << "Yes";
  }else{
    cout << "No";
  }
}


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

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}

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


signed main(void)
{
    int a, b;
    string s;
    cin >> a >> b >> s;
    
    bool flag = true;
    REP(i, s.size()) {
        if(i == a) {
            if(s[i] != '-') flag = false;
        } else {
            if(!isdigit(s[i])) flag = false;
        }
    }
    if(flag) {
        cout << "Yes" << endl; 
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
judge = True

while judge:
    H,W = list(map(int,input().split()))
    if H + W == 0 :
        judge = False
    else:
        for i in range(0, H):
            if i % 2 == 0:
                for j in range(0,W):
                    if j % 2 == 0:
                        print("#",end="")
                    else :
                        print(".",end="")
                print()
            else:
                for j in range(0,W):
                    if j % 2 == 0:
                        print(".",end="")
                    else :
                        print("#",end="")
                print()
        print()




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

int s[100000];
int t[50000];

bool binarysearch(int t,int n)
{
  int left=0;
  int right=n;
  int mid=0;

  while(left < right){
    
    mid = (left + right)/2;
    
    if(t == s[mid])
      {
	return true;
      }
    else if(t < s[mid])
      {
	right = mid;
      }
    else
      {
	left = mid + 1;
      }
  }
  return false;   
}

int main(){
  int n,q;
  int cnt=0;

  cin >> n;
  for(int i=0;i < n;i++){
    cin >> s[i];
  }
  
  cin >> q;
  for(int i=0;i < q;i++){
    cin >> t[i];
    if( binarysearch(t[i],n) ) cnt++;
  }
  
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 3580
import java.util.*;
import java.math.*;
import java.util.Arrays;

class Main{
public static void main(String args[]){
   Scanner sc = new Scanner(System.in);
   int n = Integer.parseInt(sc.next());
   int x = Integer.parseInt(sc.next())-1;
   int y = Integer.parseInt(sc.next())-1;
   int array[] = new int[n];
   Arrays.fill(array, 0);
   for (int i=0;i<n-1;i++){
     for (int j=i+1;j<n;j++){
      int l = Math.min(j-i,Math.abs(x-i)+Math.abs(y-j)+1);
      array[l-1] += 1;
     }
   }
   for (int i=0;i<n-1;i++){
     System.out.println(array[i]);
   }
   
}
}

Measured memory_bytes: 24404
#include <bits/stdc++.h>
#define RANGE(i,n) for(int i=0;i<n;i++)
typedef long long ll;
struct P{
    ll var1;
    ll var2;
};
bool operator< ( const P &one, const P &two){
    return one.var1 < two.var1;
};
bool operator> ( const P &one, const P &two){
    return one.var1 > two.var1;
};

using namespace std;

signed main() {
    int N;
    cin >> N;
    vector<int> W(N);
    int sum_l = 0;
    int sum_r = 0;
    RANGE(i,N){
        cin >> W[i];
        sum_r += W[i];
    }
    int result = INT_MAX;
    RANGE(i,N){
        sum_l += W[i];
        sum_r -= W[i];
        result = min(abs(sum_l-sum_r), result);
    }
    cout << result << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int n, m;
    cin >> n >> m;
    cout << (n * (n - 1) + m * (m - 1)) / 2;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>

int main(){
	unsigned long long n,x;
	scanf("%llu %llu",&n,&x);
	unsigned long long a[n];
	int i;
	
	for(i=0;i<n;i++){
		scanf("%llu",&a[i]);
	}
	
	unsigned long long b[n];
	for(i=0;i<n-1;i++){
		b[i]=a[i]+a[i+1];
	}//puts("");
	b[n-1]=0;//最後の項の計算のために用意
	
	unsigned long long eatenCandy = 0;
	for(i=0;i<n-1;i++){
		//printf("for %d\n",i+1);
		if(b[i]<=x){
		}else{//b[i]-xは食べないといけない数
			eatenCandy += b[i]-x;
			
			if(b[i]-x<=a[i+1]){//右側の箱から全部食べられる場合
				b[i+1]-=b[i]-x;
			}else{
				b[i+1]-=a[i+1];
			}
		}
	}
	
	printf("%llu\n",eatenCandy);
	
	return 0;
}

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

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

  ll n;
  cin >> n;

  ll ans = 0;
  for (ll i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) {
      ans = (i - 1) + (n / i) - 1;
    }
  }

  if(ans == 0) {
    ans = n - 1;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256