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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

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

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

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n, m; std::cin >> n >> m;
  map<int, int, greater<int>> cnt;
  rep(i, n) {
    int a; std::cin >> a;
    cnt[a]++;
  }
  rep(i, m) {
    int b, c; std::cin >> b >> c;
    cnt[c] += b;
  }

  int remain = n;
  ll ans = 0;
  for (auto &p : cnt) {
    ll choseNum = min(remain, p.se);
    ans += choseNum * p.fi;
    remain -= choseNum;
    if (remain == 0) break;
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vl;

const int N = 2e5 + 123;
int n, m, used[N], h[N], cnt;
int sz[N], C[2][N], cycle[N];
vi adj[N];

int t[2], tn;
pii tc;

void add(int x) {
	if (!cycle[x]) {
		for (int j = 0; j < 2; j++) {
			t[j] += C[j][x];
		}
		tn++;
	}	else {
		tc.F += sz[x];
		tc.S++;
	}
}

void del(int x) {
	if (!cycle[x]) {
		for (int j = 0; j < 2; j++) {
			t[j] -= C[j][x];
		}
		tn--;
	}	else {
		tc.F -= sz[x];
		tc.S--;
	}
}

void dfs(int v, int p) {
	used[v] = 1;
	C[h[v]][cnt]++;
	sz[cnt]++;
	for (int to : adj[v]) {
		if (to == p) {
			continue;
		}
		if (used[to] == 1) {
			if (h[to] ^ h[v] ^ 1) {
				cycle[cnt] = 1;
			}
		}
		if (used[to] == 0) {
			h[to] = h[v] ^ 1;
			dfs(to, v);
		}
	}
	used[v] = 2;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		int x, y;
		cin >> x >> y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	for (int i = 1; i <= n; i++) {
		if (!used[i]) {
			cnt++;
			dfs(i, -1);
			if (sz[cnt] == 1) {
				continue;
			}
			add(cnt);
		}
	}
	ll res = 0;
	for (int i = 1; i <= cnt; i++) {
		if (sz[i] == 1) {
			continue;
		}
		del(i);
		if (!cycle[i]) {
			res += (ll)C[0][i] * C[0][i] + (ll)C[1][i] * C[1][i] - 1;
			res += (ll)C[0][i] * C[1][i] + C[1][i] * C[0][i] - 1;
			
			res += (ll)C[0][i] * t[0] + (ll)C[1][i] * t[1] - tn;
			res += (ll)C[0][i] * t[1] + (ll)C[1][i] * t[0] - tn;
		}	else {
			res += (ll)sz[i] * tc.F - tc.S;
			res += (ll)sz[i] * (t[0] + t[1]) - tn;
			res += (ll)(t[0] + t[1]) * sz[i] - tn;
			res += (ll)sz[i] * sz[i] - 1;
		}
		add(i);
	}
	res = (ll)n * n - res;
	cout << res;
}


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

int main() {
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	cin>>arr[i];
	float per=0.0;
	for(int i=0;i<n;i++)
	{
		per=per+(1.0/arr[i]);
	}
	float res=1/per;
	cout<<res;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>

using namespace std;

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

	vector<int> vec;
	int m;
	for (int index = 0; index < n; index++) {
		cin >> m;
		vec.push_back(m);
	}
	sort(vec.begin(), vec.end());

	int total = 0;
	if (k == 1) {
		cout << vec[0] << endl;
	}
	else {
		for (int index = 0; index < k; index++) {
			total += vec[index];
		}
		cout << total << endl;
	}
	
}


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

#define ll long long
#define endl '\n'
#define pii pair<ll,ll>
#define N 100007
#define pb push_back;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);

ll check(ll a,ll b,ll c)
{
    return ((a+b>c)&&(a+c>b)&&(b+c>a));
}
int main()
{
    ll n;
    cin>>n;
    ll x;
    vector<ll> v;
    ll i,j,k;
    ll cnt=0;
    
    for(i=0;i<n;i++)
    {
        cin>>x;
        v.push_back(x);
    }
    
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            for(k=j+1;k<n;k++)
            {
                if(v[i]!=v[j]&&v[j]!=v[k]&&v[i]!=v[k])
                {
                    cnt+=(check(v[i],v[j],v[k]));
                }
            }
        }
    }
    
    cout<<cnt;
}

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

int main() {

	int n; cin >> n;

	int ans[10001] =  {0};

	for(int x = 1; x <= 100; x ++)
		for(int y = 1; y <= 100; y ++)
			for(int z = 1; z <= 100; z ++) {

				int v = x * x + y * y + z * z + x * y + y * z + z * x;

				if(v <= 10000)
					ans[v] ++;
			}

	for(int i = 1; i <= n; i ++)
		printf("%d\n", ans[i]);
}

Measured memory_bytes: 3080
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define CLR(x) memset(x,0,sizeof x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 1000000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
//orz yht
using namespace std;
string i_s(int x){
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}
int n,k,ans,res=INF;
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		res=min(res,x);
		ans++;
		k-=x;
	}
	ans+=(k/res);
	cout<<ans;
	//system("pause");
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
int a[200020];
int main() {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < k; i++) {
		bool b = true;
		for (int j = 0; j < n; j++) {
			if (a[j] != n) {
				b = false;
			}
		}
		if (b == true) {
			for (int j = 0; j < n; j++) {
				cout << a[j];
				if (j != n - 1) {
					cout << " ";
				}
			}
			cout << endl;
			return 0;
		}
		int sum[200020] = { 0 };
		for (int j = 0; j < n; j++) {
			sum[max(j - a[j], 0)] ++;
			sum[min(j + a[j] + 1, n)] --;
		}
		int co = 0;
		for (int j = 0; j < n; j++) {
			co += sum[j];
			a[j] = co;
		}
	}
	for (int j = 0; j < n; j++) {
		cout << a[j];
		if (j != n - 1) {
			cout << " ";
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 5188
if True:
    N = int(input())
    As = list(map(int, input().split()))

    maxA = 10**6 + 6
    c = [0] * (maxA+1)
    for A in As:
        c[A] += 1
    isPrime = True
    cnt = 0
    for i in range(2, maxA+1):
        cnt = sum(c[i::i])
        if cnt == N:
            # Asはすべてiの約数
            print("not coprime")
            exit()
        if cnt >= 2:
            isPrime = False
        
    else:
        if isPrime:
            print("pairwise coprime")
        else:
            print("setwise coprime")

Measured memory_bytes: 204152
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);


int main() {
	string a, b;
	while (cin >> a >> b && (a != "0" || b != "0")) {

		int a1 = 0, a2 = 0;
		rep(i, 4)a1 += a[i] == b[i];
		rep(i, 10)a2 += min(count(all(a), '0' + i), count(all(b), '0' + i));
		Cout2(a1, a2 - a1);
	}
}


Measured memory_bytes: 3140
#include <iostream>
#include <cmath>

using namespace std;
 
int main(){
    int W,H,n,nx,ny,x,y,total = 0;
 
    cin >> W >> H >> n;
    cin >> nx >> ny;
 
    for(int i = 0 ; i < n-1 ; i++){
	cin >> x >> y;
 
	int dx = abs(x - nx);
	int dy = abs(y - ny);
 
	if((x - nx)*(y - ny) >= 0){
	    total += max(dx,dy);
	}
	else total += dx + dy;
 
	nx = x;
	ny = y;
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 3096
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define show(x) cout << #x << " = " << x << endl;
int n;
int par(int v) { return (v + n - 2) / n; }
int main() {
    int q;
    cin >> n >> q;
    rep(hoge, q) {
        int v, w;
        cin >> v >> w;
        if (n == 1) {
            cout << min(v, w) << endl;
        } else {
            while (1) {
                if (v < w) {
                    w = par(w);
                } else if (v > w) {
                    v = par(v);
                } else {
                    cout << v << endl;
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 1280
from sys import stdin
input = stdin.readline


def main():
  S = input()[:-1]

  cnt = 0
  nw = 0
  for i, s in enumerate(S):
    if s == 'W':
      cnt += (i-nw)
      nw += 1

  print(cnt)


if(__name__ == '__main__'):
  main()


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

int main() {
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  int p=0;
  rep(i,n-1){
    if(s[i]==s[i+1])
    p++;
  }
  
  cout << min(p+2*k,n-1) << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    int n, A[20];
    cin >> n;
    for(int i=0;i<n;i++) cin >> A[i];
    int q, m[200];
    cin >> q;
    for(int i=0;i<q;i++) cin >> m[i];

    unordered_set<ll> S;

    for(int i=0;i<(1<<n);i++){
        ll s=0;
        for(int j=0;j<n;j++){
            if((i>>j)&1) s+=A[j];
        }
        S.insert(s);
    }

    for(int i=0;i<q;i++){
        if(S.count(m[i])>0) cout << "yes" << endl;
        else cout << "no" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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;
}
//O(k)愚直,nは大きいがkがそうでもないときに思い出す
long long modpow(long long x,long long n,long long mod){
    long long res = 1;
    while(n > 0) {
        if(n & 1) (res *= x) %= mod;
        (x *= x) %= mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long x, long long mod){
     return modpow(x, mod - 2, mod); }
long long modcomb(long long n,long long r,long long mod){
    long long numerator = 1;
    for(long long i = 0; i < r; i++) {
        (numerator *= (n - i)) %= mod;
    }
    long long denominator = 1;
    for(long long i = 1; i <= r; i++) {
        (denominator *= i) %= mod;
    }
    denominator = modinv(denominator, mod);
    return numerator * denominator % mod;
}
int main(){
    ll n, k;
    cin >> n >> k;
    cout << n - k + 1 << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define pb emplace_back
#define mp make_pair
#define int long long

using namespace std;

int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10);
	int n; cin >> n;
	int h; cin >> h;
	int w; cin >> w;
	int ans = max(n - w + 1ll, 0ll) * max(n - h + 1ll, 0ll);
	cout << ans << "\n";
}

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

int main(){
	string x, y, z;
	while(cin >> x >> y >> z){
		int xi = 0, yi = 0, zi = 0;
		char ch = y[yi++];
		string res;

		while(zi < z.size()){
			if(ch == z[zi]){
				++zi;
				ch = x[xi++];
			}
			else{
				res += ch;
				ch = y[yi++];
			}
		}
		res += ch;
		res += y.substr(yi);
		cout << res << '\n';
	}
}

Measured memory_bytes: 1172
#include <algorithm>
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int main(){
    string S;
    cin >> S;
    int ans;

    /*
    int zero=0;
    int one=0;
    */

    vector<int> cnt(2, 0);
    for(int i=0; i<S.length(); i++){
        cnt[S[i] - '0']++;
    
    /*
        if(S[i]=='0'){
           zero++;
        }else{
            one++;
        }
    */
    }
    
    /*
    if(zero <= one){
        ans = zero;
    }else{
        ans = one;
    }
    */

    ans = min(cnt[0], cnt[1]) * 2;

    cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    int n,l,r;
    long long ans=0;
    cin>>n;
    while(n--)
    {
        cin>>l>>r;
        ans+=r-l+1;
    }
    cout<<ans<<endl;
return 0;
}



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


Measured memory_bytes: 128
using System;
class sort{
    public static void Main(){
        String[] str = Console.ReadLine().Split(' ');
        int a = int.Parse(str[0]);
        int b = int.Parse(str[1]);
        int c = int.Parse(str[2]);
        int temp;
        for(int i = 0; i<3; i++){
            if(a > b){
                if(a > c){
                    temp = a;
                    a = c;
                    c = temp;
                }
                else{
                    temp = a;
                    a = b;
                    b = temp;
                }
            }
            else{
                if(b > c){
                    temp =b;
                    b = c;
                    c = temp;
                }
            }
        }
        Console.WriteLine("{0} {1} {2}",a,b,c);
    }
}


Measured memory_bytes: 17936
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <list>
#include <numeric>
using namespace std;
 
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<int, ll> i_ll;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
#define rep(i, N) for (int i = 0; i < (int)(N); i++)
#define pb push_back
 
int INF = INT_MAX / 10;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int N; cin >> N;
	vector<int> a(N);
	rep(i, N) scanf("%d", &a[i]);
	ll ans = a[0] - 1;
	int x = 2;
	for (int i = 1; i < N; i++) {
		if (a[i] == x) {
			x++;
			continue;
		}
		if (a[i] < x) continue;
		ans += a[i] / x;
		if (a[i] % x == 0) ans--;
	}
	cout << ans << endl;
}


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

const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}



vector<vector<ll>> wsmap;
ll n, m, r;

vector<ll> rr;

ll minJourney(vector<bool> chk, ll nowc, ll nowid) {

  ll cost = LLINF;
  bool isallchk = true;

  for (int i = 0; i < r; i++) {
    vector<bool> chk2 = chk;

    if (chk[i] == false) {
      ll tmpnowc = nowc;
      chk2[i] = true;
      if (nowid != -1)tmpnowc += wsmap[nowid][rr[i]];
      cost = min(minJourney(chk2, tmpnowc, rr[i]), cost);
      isallchk = false;
    }
  }

  if (isallchk) {
    return nowc;
  }


  return cost;

}

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

  vector<ll> t(n, 0);
  vector<ll> v(n, 0);

  cin >> t;
  cin >> v;



  ll allsec = 0;
    for (int i = 0; i < n; ++i){
    allsec += t[i];
  }
  allsec++;

  //       -----
  //     /
  // ---    

  cerr << allsec <<endl;


  double ans = 0;
  //全部で200 * 100秒

  vector<ll> vmap(allsec, 0);
  ll s = 0;
  ll tmptime = 0;
  for (ll i = 0; i < allsec-1; ++i){
    if (i >= tmptime + t[s] ){
      tmptime += t[s];
      s++;
    }
    vmap[i]= v[s];
  }
  vmap[allsec-1] = 0;


  vector<ll> stv(allsec, 0);
  for (ll i = 1; i < allsec; ++i){
    if (vmap[i-1] >= stv[i-1] + 1){//速度増加
      stv[i] = stv[i-1] + 1;
    }else{
      stv[i] = stv[i-1];
    }

    if ( vmap[i] <  stv[i]  ){//巻もどし処理発生
      stv[i] = vmap[i];
      for(ll j=i-1;j>=0;j--){
        if (stv[j] > stv[j+1]+1){
          stv[j] = stv[j+1]+1;
        }else{
          break;
        }
      }
    }
  }


  ll nows = 0;
  for (ll i = 1; i < allsec; ++i){
    if (stv[i] != stv[i-1]){
      ll minv = min(stv[i], stv[i-1]);
      ans += minv;
      ans += 0.5;
    }else{
      ans +=stv[i];
      if (stv[i] < vmap[i-1]){
        ans += 0.25;
        // cerr << "min "<<i <<endl;
      }
    }

  }


  cout << fixed<< setprecision(15);
  cout << ans << endl;




}




















Measured memory_bytes: 512
N, K = [int(v) for v in input().split(' ')]
A = [int(v) for v in input().split(' ')]

sum_A = sum(A)
max_A = max(A)

def make_divisor(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    return divisors

div_list = make_divisor(sum_A)
div_list.sort(reverse=True)

for d in div_list:
    R = [a % d for a in A]

    sum_r = sum(R)
    if sum_r % d != 0:
        continue

    R.sort()
    #print("%d: %s" % (d, R))
    flag = False 

    sub = 0
    flag = True
    for i in range(N):
        if flag and sub + R[i] > K:
            flag = False
            #print("%d, i: %d" % (d, i))

        if flag:
            sub += R[i]
        else:
            sub -= (d - R[i])

    #print("%d, sub: %d" % (d, sub))

    if not flag and sub < 0:
        continue

    print(d)
    exit()


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
//#include <numeric> //iota
//#include <sstream>
//#include <cstring>
//#include <tuple>
//#include <random>
//#include <string>
//#include <unordered_set>
//#include <bitset>
//#include <unordered_map>
//#include <stack>
//#include <cmath>
//#include <deque>
//#include <queue>
//#include <list>
#include <array>

using namespace std;
#define all(x) (x).begin(), (x).end()
#define vec vector
#define pb push_back
#define pp pop_back
#define fi first
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define se second
#define un_map unordered_map
#define rep(i,a,n) for (int i = a; i < n; ++i) 
#define inc_rep(i,a,n,inc) for (int i = a; i < n; i += inc) 
#define couts(x) cout << x << "\n" 
#define watch(x) cout << #x << " : " << x << endl;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<long long, long long>  PLII;
template<typename T>
void print(vector<T>& v) {rep(i, 0, (int)v.size()) cout << v[i] << " ";cout << endl;}
int nxt() {int x;cin >> x;return x;}
ll nxtl() {ll x;cin >> x;return x;}
string nxts() {string x;cin >> x;return x;}
double nxtd() {double x; cin >> x; return x;}
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
 
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


ll power_mod(ll a, ll b, ll mo) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = (ans % mo * a % mo) % mo;
		}
		a = (a % mo * a % mo) % mo;
		b /= 2;
	}
	return ans;
}
ll POW(ll a, ll b) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = ans * a;
		}
		a = a * a;
		b /= 2;
	}
	return ans;
}

int visited[100000 + 5];
vector<vector<int>> v(1e5 + 5);
void dfs(int val) {
	if (visited[val]) return ;
	visited[val] = 1;
	for (auto x : v[val]) {
		dfs(x);
	}
}


int main() {
	IOS;
	int  n, m;
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int x, y;
		cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	int cnt = 0;
	for (int  i = 1; i <= n; ++i) {
		if (!visited[i]) {
			dfs(i);
			cnt++;
		}
	}
	cout << cnt - 1;
	//cout << max(0, n - 1 - m); 
}




































Measured memory_bytes: 9676
// DPのパラメータとして、すでに最後を食べたかどうかを加える。
// すでに食べてたら普通のナップサックDP
// 食べてなかったら、現在の物を最後にする、という遷移もありになる。
// その場合、時間は増えずに評価値だけが増える。
// O(2NT) でできる。

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPI(i,f,n) for(int i=(f);i<(n);++i)
using namespace std;
typedef long long ll;

// dp[i][j][k] ： j時間を超えないように、0～i-1範囲で任意に食べた場合のMAX。k=0なら最後はまだ食べてない。
ll dp[3005][3005][2];

int main() {
  ll N, T;
  cin >> N >> T;
  vector<int> A(N), B(N);
  REP(i,N) {
    cin >> A[i] >> B[i];
  }
  REP(i,N) {
    REP( ti, T+1 ) {
      REP( k, 2 ) {
        if ( ti >= A[i]) dp[i+1][ti][k] = max(dp[i][ti-A[i]][k] + B[i], dp[i][ti][k] );
        else dp[i+1][ti][k] = dp[i][ti][k];
        if ( k == 1 ) {
          dp[i+1][ti][1] = max(dp[i][ti][0] + B[i], dp[i+1][ti][1] );
        }
      }
    }
  }
  ll ans = dp[N][T-1][1];
//  REP(i,T+1) {
//    REP(j,N+1) {
//      printf("%3lld : %3lld   ",dp[j][i][0],dp[j][i][1]);
//    }
//    cout << endl;
//  }

  cout << ans << endl;
}


Measured memory_bytes: 141184
def main():
    Input = [input() for i in range(1)]
    N = int(Input[0])
    A = 0
    for i in range(1,10):
        for j in range(1,10):
            if i*j == N:
                A = 1
    if A == 1:
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()
    


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

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a;
    cin>>a;
    
    for(int i=1; i<=a; i++){
        if(i%3==0) printf(" %d",i);
        else{
            int x = i;
            do{
                if(x%10==3){
                    printf(" %d",i);
                    break;
                }
                x/=10;
            }while(x);
        }
    }
    printf("\n");
    
    return 0;
    
}



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

int	main()
{
	string	s;
	cin >> s;
	int	idx_A = -1, idx_Z = -1;
	int	size = s.size();
	for (int i = 0; i < size; ++i) {
		if (s.at(i) == 'A') {
			idx_A = i;
			break;
		}
	}
	for (int i = size - 1; i > idx_A; --i) {
		if (s.at(i) == 'Z') {
			idx_Z = i;
			break;
		}
	}
	cout << idx_Z - idx_A + 1 << endl;
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
#define all(x) (x).begin(),(x).end()

int main(){
  int n;
  cin >> n;
  double m = n;

  if(n % 2 == 0) cout << 0.5 << ln;
  else cout << (n / 2 + 1) / m << ln;
}

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

int solution[2*100000];
int numbersUsed[2*100000];

int main() {
	int n, x;
	cin >> n >> x;
	if (x == 1 || x == 2*n - 1) {
		cout << "No";
	} else {
		cout << "Yes" << endl;
		if (x == 2) {
		solution[n] = x;
			solution[n-1] = x+1;
				solution[n+1] = x-1;
			solution[n+2] = x+2;
			numbersUsed[x] = 1;
			numbersUsed[x-1] = 1;
			numbersUsed[x+1] = 1;
			numbersUsed[x+2] = 1;
		} else {
			solution[n] = x;
			solution[n-1] = x-1;
			solution[n+1] = x+1;
			solution[n+2] = x-2;
			numbersUsed[x] = 1;
			numbersUsed[x-1] = 1;
			numbersUsed[x+1] = 1;
			numbersUsed[x-2] = 1;
		}
		int br = 1;
		for (int i = 1; i <= 2*n-1; i++) {
			if (solution[i] != 0) {
				cout << solution[i] << endl;
			} else {
				while (numbersUsed[br] == 1) {
					br++;
				}
				cout << br << endl;
				br++;
			}
		}
	}
}

Measured memory_bytes: 1536
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	K := getInt()
	S := getInt()

	ans := 0
	for x := 0; x <= K; x++ {
		for y := 0; y <= K; y++ {
			z := S - (x + y)
			if z >= 0 && z <= K {
				ans++
			}
		}
	}
	out(ans)
}


Measured memory_bytes: 640
n, k = map(int, input().split())
mod = 10**9+7

def power(a, n, mod):
    bi=str(format(n,"b")) #2進数
    res=1
    for i in range(len(bi)):
        res=(res*res) %mod
        if bi[i]=="1":
            res=(res*a) %mod
    return res

D = [0]*(k+1)
ans = 0
for i in reversed(range(1, k+1)):
    a = k//i
    d = power(a, n, mod)
    j = 1
    while i*j <= k:
        d -= D[i*j]
        j += 1
    D[i] = d
    ans += (d*i)%mod

print(ans%mod)

Measured memory_bytes: 11216
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int a[3];
    for(int i=0;i<3;i++) cin>>a[i];
    sort(a, a+3);
    if(a[0]+a[1]==a[2]) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
int main() {
  int a[5],Min=10,ans=0;
  rep(i,5){
    cin >> a[i];
    if(a[i]%10==0)ans+=a[i];
    else {
      ans += (a[i]/10 + 1) *10;
      Min = min(Min,a[i]%10);
    }
  }
  cout << ans + Min -10;
}

Measured memory_bytes: 3536
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <queue>
using namespace std;

struct Edge {
    int to;
    int timeCost;
    int silverCost;
    Edge() {
    }

    Edge(int pt, int ptc, int psc) : to(pt), timeCost(ptc), silverCost(psc) {
    }
};

struct Node {
    int now;
    int silver;
    long long timeCost;
    Node() {
    }

    Node(int n, int s, long long t) : now(n), silver(s), timeCost(t) {
    }

    bool operator<(const Node& n) const {
        return timeCost > n.timeCost; // reverse pq order
    }
};

using VLL = vector <long long>;
using VVLL = vector< VLL >;

using VI = vector <int>;
using VVI = vector< VI >;

using VE = vector<Edge>;
using VVE = vector<VE>;

const long long INF = 1000000LL * 1000000000LL;

int main() {
    int N;
    int M;
    int S;

    cin >> N >> M >> S;

    VVE adja(N);

    VI goldSilver(N);
    VI goldTime(N);

    for (int i = 0; i < M; ++i) {
        int from;
        int to;
        int T;
        int C;
        cin >> from >> to >> C >> T;
        --from;
        --to;
        adja[from].emplace_back(Edge(to, T, C));
        adja[to].emplace_back(Edge(from, T, C));
    }

    for (int i = 0; i < N; ++i) {
        cin >> goldSilver[i] >> goldTime[i];
    }

    const int UPPER = 50;
    int MAXSILV = UPPER*N + UPPER;

    VVLL best(N, VLL(MAXSILV + 1, INF));

    priority_queue < Node > pq;
    pq.push(Node(0, min(S, MAXSILV), 0));
    best[0][min(S, MAXSILV)] = 0;

    while (!pq.empty()) {
        Node now = pq.top();
        pq.pop();
        int nowv = now.now;

        if (now.timeCost > best[nowv][now.silver]) {
            continue;
        }

        for (int i = 0; i < adja[nowv].size(); ++i) {
            int nextv = adja[nowv][i].to;

            for (int j = 0; true; ++j) {
                int newS = now.silver + j*(long long)goldSilver[nowv];
                long long timeCost = best[nowv][now.silver] + j*(long long)goldTime[nowv];

                if (newS <= MAXSILV || j == 0) {
                    int nnewS = newS - adja[nowv][i].silverCost;
                    if (nnewS < 0) {
                        continue;
                    }
                    long long nnewT = timeCost + adja[nowv][i].timeCost;

                    if (nnewT < best[nextv][nnewS]) {
                        best[nextv][nnewS] = nnewT;
                        pq.push(Node(nextv, nnewS, nnewT));
                    }
                } else {
                    break;
                }
            }
        }
    }

    for (int i = 1; i < N; ++i) {
        long long minVal = INF;
        for (int j = 0; j <= MAXSILV; ++j) {
            minVal = min(minVal, best[i][j]);
        }

        cout << minVal << endl;
    }

    return 0;
}

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

using namespace std;

int main(void){
  int N;
  cin >> N;

  int ans = 0;
  for (int i = 0; i < 9;i++){
    ans += 111;
    if(N<=ans){
      cout << ans << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
def main():
    n = 90
    a = [0 for i in range(n)]
    a[0],a[1] = 2,1

    for i in range(2,n):
        a[i] = a[i-1]+a[i-2]

    print(a[int(input())])

if __name__ == '__main__':
    main()


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

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

    int n;
    char ch;

    n=s.size();
    ch=s[n-1];

    cout<<s;
    if(ch=='s')
    {
        cout<<"es"<<endl;
    }
    else
        cout<<"s"<<endl;
    return 0;
}


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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
typedef pair<ll, ll> P;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
const ll INF = 10e14;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}


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

    t.pop_back();
    if (s == t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}





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

using namespace std;
const int mod = 1000000007;
const int N = 200005;

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
/* #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif	 */
	int n,k;
	cin>>n>>k;
	int arr[n];
	vector<int> ans(n,INT_MAX);
	for(int i=0;i<n;i++)
		cin >> arr[i];
	ans[0] = 0;
	for(int i=0;i<n-1;i++){
		for(int j=1;j<=k && i+j < n;j++){
			ans[i+j] = min(ans[i+j],ans[i]+abs(arr[i] - arr[i+j]));
		}
	}
	cout<<ans[n-1];
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstring>

const int LEN = 100005;

typedef struct pp
{
	char name[100];
	int t;
} P;

P Q[LEN];

int head, tail, n;

void enqueue(P x)
{
	Q[tail] = x;
	tail = (tail + 1) % LEN;
}

P dequeue()
{
	P x = Q[head];
	head = (head + 1) % LEN;
	return x;
}

int min(int a, int b)
{
	return a < b ? a : b;
}

int main()
{
	using namespace std;
	int elaps = 0, c;
	int q;
	P u;
	cin >> n >> q;
	for (int i = 0; i < n; i++)
	{
		cin >> Q[i].name;
		cin >> Q[i].t;
	}
	head = 0, tail = n;
	while (head != tail)
	{
		u = dequeue();
		c = min(q, u.t);	//execute for time q or u.t
		u.t -= c;			//calculate the remaining time
		elaps += c;			//calculate the time elapsed
		if (u.t > 0)enqueue(u);
		else cout << u.name << ' ' << elaps << endl;
	}
	return 0;
}


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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.length()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>())
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////
	int a[3];
	int b = 0;
	int c = 0;
	cin >> a[0] >> a[1] >> a[2];
	REP(i,3){
		if(a[i]==5) b++;
		if(a[i]==7) c++; 
	}
	cout << (b==2 && c==1 ? "YES" : "NO") << endl;

	
//////////////////////////////////////////////
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int n;
void dfs(string s, char mx){
	if (s.size() == n){
		cout << s << endl;
		return;
	}
	for (char c = 'a'; c <= mx+1; c++){
		string t = s;
		t += c;
		dfs(t, max(mx, c));
	}
}

int main() {
	cin >> n;
	dfs("",'a'-1);
    return 0;
}


Measured memory_bytes: 1536
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>

#define INF 1e18
#define MOD 1000000007

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order(); order_of_key();

int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    set<string> s;
    for(int i = 0; i < n; i++) {
        string x;
        cin >> x;
        s.insert(x);
    }
    cout << s.size() << "\n";
}


Measured memory_bytes: 19252
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
// #define mp make_pair
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) (n>=r?((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod):0LL)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\n'
// #define int ll
vector<ll> ft(1, 1LL);

/*======================================================================*/


void solve(){
    int a, b, k;
    cin >> k >> a >> b;
    rep(i, a, b+1){if(i%k == 0){cout << "OK";return;}}
    cout << "NG";
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3640
# ABC107
# B
# Grid Compression

h, w = map(int, input().split())
a_list = []
for i in range(h):
    _tmp = input()
    if set(_tmp).issuperset({"#"}):
        a_list.append(_tmp)

a_list_T = [list(x) for x in zip(*a_list)]
tmp_list = []

for i in range(w):
    _tmp = a_list_T[i]
    if set(_tmp).issuperset({"#"}):
        tmp_list.append(_tmp)
        
ans = [list(x) for x in zip(*tmp_list)]

for _l in ans:
  print(*_l,sep="")


Measured memory_bytes: 4596
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
using namespace std;

#define INF 10000000

struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};

void dfs(vector<edge>& edges,vector<bool>& seen,int i) {
    seen[i] = true; // v を訪問済にする
    
    // v から行ける各頂点 next_v について
    for (auto edge : edges) {
//        cout << i << endl;
        if (edge.from == i){
            if (seen[edge.to] == false){
                dfs(edges, seen, edge.to);
            }
        }
    }
}

void dfs2(vector<edge>& edges,vector<bool>& seen,int i) {
    seen[i] = true; // v を訪問済にする
    
    // v から行ける各頂点 next_v について
    for (auto edge : edges) {
        //        cout << i << endl;
        if (edge.to == i){
            if (seen[edge.from] == false){
                dfs2(edges, seen, edge.from);
            }
        }
    }
}

int main() {
    
    int N,M,P;
    bool flag = 1;

    cin >> N;
    cin >> M;
    cin >> P;
    
    vector<int> vertex(N);
    vector<edge> edges;
    
    fill(vertex.begin(),vertex.end(),INF);
    for (int i = 0; i < M; i++)
    {
        int from, to, cost;
        struct edge add;

        cin >> from;
        cin >> to;
        cin >> cost;
        
        add.from = from - 1;
        add.to = to - 1;
        add.cost = (cost - P)*(-1);
        edges.push_back(add);
    }
    
    vertex[0] = 0;
    
    // 深さ優先探索
    vector<bool> from_start(N);
    vector<bool> from_goal(N);
    vector<bool> seen(M);
    
    dfs(edges,from_start,0);
    dfs2(edges,from_goal,N-1);
    
    for(int i=0; i<M; i++){
        if(from_start[edges[i].from] == true &&
                from_goal[edges[i].from] == true){
            seen[i] = true;
//            cout << i << endl;
        }
        
    }
    
    for (int i=0; i<N+1; i++){
        for(int j=0; j<M; j++){
            if(seen[j] == true){
                if(vertex[edges[j].to] > vertex[edges[j].from] +edges[j].cost){
                    vertex[edges[j].to] = vertex[edges[j].from] +edges[j].cost;
                    if(i == N){
                            flag = 0;
                            break;
                    }
                }
            }
            
        }
    }
    
    if (flag == 1){
        if (vertex[N-1] > 0){
            vertex[N-1] = 0;
        }
            cout << vertex[N-1]*(-1) << endl;
    }
    else{
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 512
import numpy as np
w, h, n = map(int, input().split())

mat = np.ones(w * h).reshape(h, w)
for _ in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        mat[:, :x] = 0
    elif a == 2:
        mat[:, x:] = 0
    elif a == 3:
        mat[-y+h:, :] = 0
    else:
        mat[:-y+h, :] = 0
print(len(mat[mat == 1]))


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

ll dp[200001][3];

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

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

    memset(dp, 0xc0, sizeof(dp));

    if (n % 2 == 0) {
        for (int i = 0; i < 2; i++) dp[i][i] = a[i];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 2; j++) {
                if (i - 2 >= 0) dp[i][j] = max(dp[i][j], dp[i - 2][j] + a[i]);
                if (i - 3 >= 0 && j - 1 >= 0) dp[i][j] = max(dp[i][j], dp[i - 3][j - 1] + a[i]);
            }
        }
        ll ans = max({dp[n - 2][0], dp[n - 1][1]});
        cout << ans << endl;
    } else {
        for (int i = 0; i < 3; i++) dp[i][i] = a[i];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 3; j++) {
                if (i - 2 >= 0) dp[i][j] = max(dp[i][j], dp[i - 2][j] + a[i]);
                if (i - 3 >= 0 && j - 1 >= 0) dp[i][j] = max(dp[i][j], dp[i - 3][j - 1] + a[i]);
                if (i - 4 >= 0 && j - 2 >= 0) dp[i][j] = max(dp[i][j], dp[i - 4][j - 2] + a[i]);
            }
        }
        ll ans = max({dp[n - 3][0], dp[n - 2][1], dp[n - 1][2]});
        cout << ans << endl;
    }
    return 0;
}


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

using namespace std;

int main(void)
{
    string s;
    cin >> s;
    if(s =="Sunny")
        cout << "Cloudy" << endl;
    else if(s == "Cloudy")
        cout << "Rainy" << endl;
    else
        cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<iomanip>
#include<array>

//#define P(p) pow 

using namespace std;

int main(){
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		array<pair<double,double>,3>p;
		cin>>p[0].first>>p[0].second>>p[1].first>>p[1].second>>p[2].first>>p[2].second;

		pair<long double, long double >o(
			 ((p[2].second - p[1].second) * (pow(p[1].first, 2.0) - pow(p[0].first, 2.0) + pow(p[1].second, 2.0) - pow(p[0].second, 2.0)) - (p[1].second - p[0].second) * (pow(p[2].first, 2.0) - pow(p[1].first, 2.0) + pow(p[2].second, 2.0) - pow(p[1].second, 2.0))) / (2.0 * ((p[1].first - p[0].first) * (p[2].second - p[1].second) - (p[1].second - p[0].second) * (p[2].first - p[1].first))),
                (- (p[2].first - p[1].first) * (pow(p[1].first, 2.0) - pow(p[0].first, 2.0) + pow(p[1].second, 2.0) - pow(p[0].second, 2.0)) + (p[1].first - p[0].first) * (pow(p[2].first, 2.0) - pow(p[1].first, 2.0) + pow(p[2].second, 2.0) - pow(p[1].second, 2.0))) / (2.0 * ((p[1].first - p[0].first) * (p[2].second - p[1].second) - (p[1].second - p[0].second) * (p[2].first - p[1].first)))
				);

		long double r=sqrt(pow(p[0].first - o.first, 2) + pow(p[0].second - o.second, 2));

		cout<<fixed<<setprecision(3)<<o.first<<" "<<o.second<<" "<<r<<endl;
	}
	return 0;
	
}


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

vector<long> p;

long gcd(long A, long B){
  if(B==0) return A;
  return gcd(B, A%B);
}

int main(){
  long A, B;
  cin >> A >> B;
  long g = gcd(A,B);
  long tmp = g;
  for(long i=2; i<=ceil(sqrt(g)); i++){
    long itr=0;
    while(tmp%i==0){
      if(itr==0) p.push_back(i);
      tmp/=i;
      itr++;
    }
  }
  if(tmp!=1) p.push_back(tmp);
  cout << p.size()+1 << endl;
  return 0;
}

Measured memory_bytes: 384
from heapq import*
def dijkstra(s,e):
  g=10**6
  d=[10**18]*n
  f=[1]*n
  d[s]=f[s]=0
  q=[]
  for a,b in e[s]:heappush(q,a*g+b)
  while q:
    m=heappop(q)
    if f[m%g]<1:continue
    v=m%g
    x=d[v]=m//g
    f[v]=0
    for y,w in e[v]:
      if f[w]:heappush(q,(x+y)*g+w)
  return d
(n,m,s,t),*z=[map(int,t.split())for t in open(0)]
e,f=eval('[[]for _ in"_"*n],'*2)
for u,v,a,b in z:
  u-=1
  v-=1
  e[u]+=(a,v),
  e[v]+=(a,u),
  f[u]+=(b,v),
  f[v]+=(b,u),
a=[]
m=0
for y,s in zip(dijkstra(s-1,e)[::-1],dijkstra(t-1,f)[::-1]):
  m=max(m,10**15-y-s)
  a+=m,
print(*a[::-1])

Measured memory_bytes: 109928
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def f(num, s):
    if s > num * 5:
        return False

    return True


def main():
    X = int(input())
    num = X // 100
    while True:
        s = X - num * 100
        if f(num, s):
            print(1)
            return
        elif s > num * 5:
            print(0)
            return
        num -= 1


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060