akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	int sum = 0;
	int suma = 0;
	cin >> n;
	
	vector<int>v(n);
	
	
	
	for(int i=0; i<n; i++) {
		
		cin >> v[i];
		
	}
	
	for(int i=0; i<n; i++) {
		
		suma += v[i];
		
	}
	
	int mini = 100000;
	
	for(int i=0; i<n; i++) {
		
	
		sum = 0;
		
		for(int j=0; j<i; j++) {
			
			sum += v[j];
			
		}
		
		int d = suma - 2 * sum;
		
		d = abs(d);
		
		if(d < mini) {
			
			mini = d;
			
		}
		
	}
	
	cout << mini << endl;
	
    return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
using namespace std;

int main(){
	int N, M, i, tmp;
	cin >> N >> M;
	vector<int> A;
	for(i=0; i<N; i++){
		cin >> tmp;
		A.push_back(tmp);
	}
	
	sort(A.begin(), A.end(), greater<int>());
	
	int sum = accumulate(A.begin(), A.end(), 0);
	if(A[M-1]*4*M<sum)	cout << "No" << endl;
	else			cout << "Yes" << endl;
	
	return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const ll INF=1e18;
const int MOD=1e9+7;
const double pi=acos(-1);
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
  int n,m;
  cin >> n >> m;
  UnionFind tree(n+m);
  rep(i,n){
    int k;
    cin >> k;
    rep(j,k){
      int l;
      cin >> l;
      tree.unite(i,n+l-1);
    }
  }
  rep(i,n){
    if(!tree.same(0,i)){
      cout <<"NO"<<endl;
      return 0;
    }
  }
  cout <<"YES"<<endl;
  return 0;
}


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

int main()
{
    int n, k;

    cin >> n >> k;
    vector<int>d_vec(k, 0);
    for (int i = 0; i < k; ++i) {
        cin >> d_vec[i];
    }

    int price = n;
    while (true){
        bool isValid = true;
        int digit_cnt = floor(log10(price));
        int now = price;
        for (int digit = 0; digit < digit_cnt+1; ++digit) {
            int tmp = now % 10;
            auto iter = find(d_vec.begin(), d_vec.end(), tmp);
            if (iter != d_vec.end()){
                isValid = false;
                break;
            }
            now /= 10;
        }

        if (isValid){
            cout << price << endl;
            break;
        }


        price++;
    }
    return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int a, b, c;

int main() {
	cin >> a >> b >> c;
	
	cout << (b - a == c - b ? "YES" : "NO") << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int MOD = 1000000007;
main(){
    ll N,maxi = 1;
    cin >> N;
    for(ll i = 2;i*i <= N;i++){
        if(N % i == 0){
            maxi = max(maxi,i);
        }
    }
    cout << floor(log10(max(maxi,N/maxi))+1) << endl;
}

Measured memory_bytes: 256
// 2014/06/20 Tazoe

#include <iostream>
#include <string>
using namespace std;

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

		if(s=="0")
			break;

		int A = 0, B = 0;

		for(int i=1; i<s.size(); i++){
			if(s[i]=='A'){
				A++;
			}
			else{
				B++;
			}
		}

		if(A>B){
			A++;
		}
		else{
			B++;
		}

		cout << A << ' ' << B << '\n';
	}

	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define db(a) cout << fixed << #a << " = " << a << endl;

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	if (n % 10 == 2 || n % 10 == 4 || n % 10 == 5 || n % 10 == 7 || n % 10 == 9) {
		cout << "hon" << endl;
	} else if (n % 10 == 3) {
		cout << "bon" << endl;
	} else {
		cout << "pon" << endl;
	}
}



Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
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; }

int h, w;
vector<string> fld;
int dist[30][30];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    cin >> h >> w;
    fld.resize(h);
    rep(i, h) cin >> fld[i];

    int ans = -1;
    for (int sx = 0; sx < w; sx++) {
        for (int sy = 0; sy < h; sy++) {
            if (fld[sy][sx] == '#') continue;
            rep(i, 30) rep(j, 30) dist[i][j] = INF;
            dist[sy][sx] = 0;

            queue<pii> q;
            q.push(make_pair(sy, sx));
            while (!q.empty()) {
                pii now = q.front(); q.pop();
                int x = now.second;
                int y = now.first;
                rep(i, 4) {
                    int nx = x + dx[i];
                    int ny = y + dy[i];
                    if (ny < 0 || ny >= h || nx < 0 || nx >= w || fld[ny][nx] == '#') continue;
                    if (dist[ny][nx] == INF) {
                        dist[ny][nx] = dist[y][x] + 1;
                        q.push(make_pair(ny, nx));
                    }

                }
            }

            int tmp = -1;
            rep(i, h) {
                rep(j, w) {
                    if (fld[i][j] != '#')chmax(tmp, dist[i][j]);
                }
            }
            chmax(ans, tmp);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#create date: 2020-09-19 21:00

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    s = ns()
    if s[-1] == "s":
        print(s + "es")
    else:
        print(s + "s")

if __name__ == "__main__":
    main()

Measured memory_bytes: 9108
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
vector<int>v;
int a[200005];
signed main()
{
	int n;
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>a[i];
		v.pb(i-a[i]);
	}
	sort(all(v));
	int ans=0;
	for (int i=0;i<n;i++){
		int y=a[i]+i;
		int ptr=upper_bound(all(v),y)-lower_bound(all(v),y);
		ans+=ptr;
	}
	cout<<ans;
	re 0;
}

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

int main()
{
    int N, A;

    cin >> N;
    int max_op_times = 30;
    int cnt;

    for (int i = 0; i < N; i++)
    {
        cnt = 0;
        cin >> A;
        while (A % 2 == 0)
        {
            cnt++;
            A /= 2;
        }
        max_op_times = min(cnt, max_op_times);
    }
    cout << max_op_times << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>

using namespace std;

vector<pair<int , int>> d(8);
int H, W;

int cntmine(int x, int y, vector<vector<char>> &V){
  int a = 0;
  for(int i = 0; i < d.size(); i++){
    int dx = x + d[i].first;
    int dy = y + d[i].second;
    if(dx >= W || dy >= H || dx < 0 || dy < 0) continue;
    //cout << dx << " " << dy << endl;
    if(V[dy][dx] == '#') a++;
  }
  return a;
}

int main(){
  d[0] = make_pair(0,1);
  d[1] = make_pair(1,0);
  d[2] = make_pair(0,-1);
  d[3] = make_pair(-1,0);
  d[4] = make_pair(1,1);
  d[5] = make_pair(1,-1);
  d[6] = make_pair(-1,1);
  d[7] = make_pair(-1,-1);
  
  cin >> H >> W;
  vector<vector<char>> V(H, vector<char> (W,'.'));
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++) cin >> V[i][j];
  }
  
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      char c;
      c = V[i][j];
      if(c == '.') V[i][j] = cntmine(j,i,V) + '0';
    }
  }
  
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      char c;
      c = V[i][j];
      cout << c;
    }
    cout << endl;
  }
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  vector<bool> prime_p(N + 5, true);
  prime_p[0] = prime_p[1] = false;
  for (int i = 2; i <= N; ++i) {
    if (not prime_p[i]) { continue; }
    for (int j = i * i; j <= N; j += i) {
      prime_p[j] = false;
    }
  }

  vector<int> occs(N + 5, 0);
  for (int i = 2; i <= N; ++i) {
    for (int p = 2; p <= N; ++p) {
      if (not prime_p[p]) { continue; }
      if (i % p != 0) { continue; }
      int cnt = 0, val = i;
      while (val % p == 0) {
        ++cnt;
        val /= p;
      }
      occs[p] += cnt;
    }
  }
  ll ans = 1;
  for (int i = 2; i <= N; ++i) {
    if (not prime_p[i]) { continue; }
    if (occs[i] > 0) {
      ans = (ans * (1 + occs[i])) % MOD;
    }
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    cnt = dict()
    ans = dict()
    for i in a:
        cnt[i] = cnt.get(i, 0) + 1

    for (idx, v) in cnt.items():
        ans[idx] = v * (v - 1) // 2

    sum_ = sum(ans.values())

    for k in range(len(a)):
        res = sum_ - (cnt[a[k]] - 1)
        print(res)



Measured memory_bytes: 32800
#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

using namespace std;

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

	int N_half = 100;
	
	map<int, int> score;

	for(int i = 1; i < N_half; i++){
		for(int j = 1; j < N_half; j++){
			for(int k = 1; k < N_half; k++){
				int ans = i * i + j * j + k * k + i * j + j * k + k * i;	
				if(ans <= N){
					if(score.count(ans)){
						score.at(ans)++;
					}
					else{
						score[ans] = 1;
					}
				}	
			}
		}
	}

	for(int i = 1; i <= N; i++){
		if(score.count(i)){
			cout << score.at(i) << "\n";
		}
		else{
			cout << 0 << "\n";
		}
	}
}


Measured memory_bytes: 3928
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;
int n;
double dp[305][305][305];

double calc(int x, int y, int z){
    if(dp[x][y][z] > 0) return dp[x][y][z];
    int sum = x + y + z;
    if(sum == 0) return 0;
    double res = 0;
    res = 1.0 * n / sum;
    if(x > 0) res += calc(x - 1, y, z) * x / sum;
    if(y > 0) res += calc(x + 1, y - 1, z) * y / sum;
    if(z > 0) res += calc(x, y + 1, z - 1) * z / sum;
    return  dp[x][y][z] = res;
}

int main(){
    cin >> n;
    vector<int> c(3);
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        c[x - 1]++;
    }
    double ans = calc(c[0], c[1], c[2]);
    cout << fixed << setprecision(15) << ans << endl;
    return 0;
}


Measured memory_bytes: 219392
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
const ll MOD=998244353;

int main(){
  int N, R; cin >> N >> R;
  if(N<10){
    cout << R + 100*(10-N) << endl;
  }
  else cout << R << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
int main(void)
{
  for(;;){
    int w,d;
    cin >> w >> d;
    if(!w&&!d) return 0;
    vector<int> h[2];
    h[0].resize(w);
    REP(i,w) cin >> h[0][i];
    h[1].resize(d);
    REP(i,d) cin >> h[1][i];
    int hh[2][32];
    REP(i,2) REP(j,32) hh[i][j]=0;
    REP(i,w) ++hh[0][h[0][i]];
    REP(i,d) ++hh[1][h[1][i]];
    int answer=0;
    REP(i,w) answer+=h[0][i];
    REP(i,d) answer+=h[1][i];
    REP(i,32) answer-=min(hh[0][i],hh[1][i])*i;
    cout << answer << endl;
  }
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	if(!(s[0] == s[1] && s[1] == s[2])) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

int main() {
	int n; cin >> n;
	vll a(n);
	vector<vll> dp(n, vll(n));
	for (int i = 0; i < n; i++){
		cin >> a[i];
		dp[i][i] = a[i];
	}

	for (int dx = 1; dx < n; dx++){
		for (int l = 0; l + dx < n; l++){
			int r = l + dx;
			dp[l][r] = max(a[l] - dp[l + 1][r], a[r] - dp[l][r - 1]);
		}
	}
	cout << dp[0][n - 1] << endl;

}


Measured memory_bytes: 70784
<?php
$n = trim(fgets(STDIN));
$s = trim(fgets(STDIN));
$x[] = 0;
$i = 0;
while($i < $n){
if($s[$i] == "I"){
$x[$i + 1] = $x[$i] + 1;
}else{
$x[$i + 1] = $x[$i] - 1;
}
++$i;
}
echo max($x);

Measured memory_bytes: 3700
#include <iostream>
#include <cmath>
#include <cstdio>
#include <string>
#include <set>
using namespace std;
const long D = 1000000007;

long max(long a, long b)
{
  long as = to_string(a).length();
  long bs = to_string(b).length();
  return as > bs ? as : bs;
}

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

  long min = D;
  for (long i = 1; i <= sqrt(n); i++)
  {
    if (n % i != 0)
      continue;
    if (max(i, n / i) < min)
    {
      min = max(i, n / i);
    }
  }
  cout << min << endl;

  return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
s=list(input())
ans=2*k
for i in range(n-1):
  if s[i]==s[i+1]=='R':
    ans+=1
for i in range(1,n):
  if s[i]==s[i-1]=='L':
    ans+=1
print(min(ans,n-1))

Measured memory_bytes: 4024
N, W = map(int, input().split())

items = []
for _ in range(N):
    w, v = map(int, input().split())
    items.append((v, w))

w0 = items[0][1]
itemGrp = [[] for _ in range(4)]
for v, w in items:
    itemGrp[w - w0].append(v)

for i in range(4):
    itemGrp[i].sort(reverse=True)

accItemGrp = []
for i in range(4):
    item = itemGrp[i]
    accValue = [0] * (len(item) + 1)
    for i in range(1, len(item) + 1):
        accValue[i] = accValue[i - 1] + item[i - 1]
    accItemGrp.append(accValue)

ans = 0
for n0 in range(len(itemGrp[0]) + 1):
    for n1 in range(len(itemGrp[1]) + 1):
        for n2 in range(len(itemGrp[2]) + 1):
            for n3 in range(len(itemGrp[3]) + 1):
                weight = (n0 + n1 + n2 + n3) * w0 + n1 + 2 * n2 + 3 * n3
                if weight <= W:
                    value = 0
                    for i, n in enumerate([n0, n1, n2, n3]):
                        value += accItemGrp[i][n]
                    ans = max(ans, value)

print(ans)


Measured memory_bytes: 46188
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'


void solve(){
  string s;
  cin >> s;
  int ans = 0;
  int cnt = 0;
  for (auto &c: s){
    int ok = 0;
    for (auto x: "ACGT"){
      if (x == c)
        ok |= 1;
    }
    if (ok) cnt++;
    else {
      setmax(ans, cnt);
      cnt = 0;
    }
  }
  cout << max(cnt, ans) << endl;
}

int main() {
  ios::sync_with_stdio(false);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

1
322123


n - 1
0 ... (n-1) [res ... res] S - (n-1) ... S


 */

Measured memory_bytes: 256
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>*/
 
#define pb push_back
#define mp make_pair
#define sz(s) ((int)(s.size()))
#define all(s) s.begin(), s.end()
#define rep(i, a, n) for (int i = a; i <= n; ++i)
#define per(i, n, a) for (int i = n; i >= a; --i)
#define onlycin ios_base::sync_with_stdio(false); cin.tie(0) 
using namespace std;
// using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
/*typedef tree<
pair < int, int >,
null_type,
less< pair < int, int > >,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;*/
// find_by_order() order_of_key()
const int MAXN = (int)5e5+228;
const char nxtl = '\n';
const int mod = (int)1e9+7;
const double eps = (double)1e-7;
template<typename T> inline bool updmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;}
template<typename T> inline bool updmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;}

ll n, k, a[MAXN];

int main() {
	#ifdef accepted
		freopen(".in", "r", stdin);
		freopen(".out", "w", stdout);
	#endif
	onlycin;
	cin >> k;
	rep(i, 1, k) cin >> a[i];
	ll l = 2, r = 2;
	per(i, k, 1) {
		updmax(l, (l + a[i] - 1) / a[i] * a[i]);
		if(l / a[i] * a[i] > r) {
			cout << -1;
			return 0;
		}
		updmax(r, (r + a[i]) / a[i] * a[i] - 1);
	}
	ll ch = l, ch2 = r;
	rep(i, 1, k) {
		ch = ch / a[i] * a[i];
ch2 = ch2/a[i]*a[i];
	}
	if(ch != 2 || ch2 !=  2) cout << -1;
	else cout << l << ' '<< r << nxtl;
	
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    char s[111];
    scanf("%s", s);
    int i, j, k, x;
    int max = 0;
    for (i = 0; i < n - 1; i++){
        x = 0;
        for (j = 0; j < 26; j++){
            int p;
            p = 0;
            for(k=0;k<=i;k++)
                if (s[k] == 'a' + j){
                    p++;
                    break;
                }
            if (p == 0)
                continue;
            p = 0;
            for(k=i+1;k<n;k++)
                if (s[k] == 'a' + j){
                    p++;
                    break;
                }
            if (p > 0)
                x++;
        }
        if (max < x)
            max = x;
    }
    printf("%d\n", max);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

ll N, X;
ll a[51], p[51];

ll F(ll N, ll X) {
    if(N == 0) {
        if(X <= 0) return 0;
        return 1;
    }
    if(X == 1) return 0;
    if(X <= 1 + a[N - 1]) {
        return F(N - 1, X - 1);
    }
    if(X <= 2 + 2 * a[N - 1]) {
        return p[N - 1] + 1 + F(N - 1, X - 2 - a[N - 1]);
    }
    return 2 * p[N - 1] + 1;
}

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

    cin >> N >> X;
    a[0] = 1;
    p[0] = 1;
    rep(i, 1, N + 1) {
        a[i] = a[i - 1] * 2 + 3;
        p[i] = p[i - 1] * 2 + 1;
    }

    cout << F(N, X) << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
using namespace std;
 
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
	
int a[N];
int pref[N];

int32_t main() {
	fast;
	int n;
	cin>>n;
	int res = 0;
	for(int i=1; i<=n; i++) cin>>a[i];
	pref[n] = a[n];
	for(int i=n-1; i>=1; i--)
		pref[i] = (pref[i+1] + a[i])%mod;
	for(int i=1; i<n; i++)
		res += ( a[i]%mod * (pref[i+1]%mod) )%mod;
	cout<<res%mod;
}




Measured memory_bytes: 6776
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SMALLPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
ll inf=100100100100;
const int mod=1000000007;
void chmin(auto &a,auto b){if(b<a)a=b;}
void chmax(auto &a,auto b){if(a<b)a=b;}
int main(){
  int n,m;cin>>n>>m;
  vector<P> p(m);
  rep(i,m){
    int a,b,s=0;cin>>a>>b;
    rep(j,b){
      int c;cin>>c;
      s|=(1<<(c-1));
    }
    p[i]=P(a,s);
  }
  vi dp((1<<n),inf);
  dp[0]=0;
  rep(s,(1<<n))rep(t,m)chmin(dp[s|(p[t].second)],dp[s]+p[t].first);
  if(dp[(1<<n)-1]==inf)cout<<-1<<endl;
  else cout<<dp[(1<<n)-1]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <complex>

using namespace std;

const double EPS = 1e-10;

typedef complex<double> P;
typedef pair<P,double> circle;

struct L { P p, q; L(P p, P q) : p(p), q(q) {} };

double cross(P a, P b) { return imag(conj(a)*b); }

bool ssIntersect(L a, L b){
	if(abs(imag((a.q-a.p)/(b.q-b.p)))<EPS) return false;
	return cross(a.q-a.p, b.p-a.p)*cross(a.q-a.p, b.q-a.p) < 0 &&
    	   cross(b.q-b.p, a.p-b.p)*cross(b.q-b.p, a.q-b.p) < 0;
}

void crossPoint(vector<P> &res, circle c1, circle c2){
	double r1 = c1.second;
	double r2 = c2.second;
	double r3 = abs(c1.first-c2.first);
	double rc = (r3*r3+r1*r1-r2*r2)/(2*r3);
	double rs = sqrt(r1*r1-rc*rc);
	P dif = (c2.first-c1.first)/r3;
	res.push_back(c1.first+dif*P(rc, rs));
	res.push_back(c1.first+dif*P(rc,-rs));
}

int main(){
	int n;
	while(cin >> n, n){
		vector<circle> vc(n);
		for(int i=0;i<n;i++){
			int x, y, r; cin >> x >> y >> r;
			vc[i] = make_pair(P(x,y), r);
		}
		vector<P> vp;
		vp.push_back(vc[0].first);
		for(int i=0;i+1<n;i++) crossPoint(vp, vc[i], vc[i+1]);
		vp.push_back(vc.back().first);

		vector<double> dist(2*n, 1e12);
		dist[0] = 0;
		for(int i=0;i<2*n;i++){
			for(int j=i+1;j<2*n;j++){
				bool ok = true;
				for(int k=(i+1)/2+1;ok && k<(j+1)/2;k++)
					ok &= ssIntersect(L(vp[i], vp[j]), L(vp[2*k-1], vp[2*k]));
				if(ok) dist[j] = min(dist[j], dist[i]+abs(vp[i]-vp[j]));
			}
		}
		printf("%.8lf\n", dist[2*n-1]);
	}
}

Measured memory_bytes: 984
import math
n = int(input())
ans = [0 for _ in range(10001)]

for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            t = x**2 + y**2 + z**2 + x*y + y*z + z*x 
            if t <= 10000:
                ans[t] += 1
for i in range(1,n+1):
    print(ans[i])

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

int main() {
    string S;
    cin >> S;
    vector<string> day = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    rep(i, 7){
        if (S == day.at(i)){
            cout << 7 - i << endl;
        }
    }
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);

const int MOD = 10000;

int menu[101];
int dp[101][4][4];

int main() {
	int n, k;
	cin >> n >> k;
	int a, b;
	for (int i = 0; i < n; i++) {
		menu[i] = -1;
	}
	for (int i = 0; i < k; i++) {
		cin >> a >> b;
		menu[a - 1] = b - 1;
	}
	for (int i = 0; i < 3; i++) {
		if (menu[0] == -1 || menu[0] == i)dp[0][i][0] = 1;
	}
	for (int i = 0; i < n - 1; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 2; k++) {
				if (dp[i][j][k] > 0) {
					for (int l = 0; l < 3; l++) {
						if (menu[i + 1] == -1 || menu[i + 1] == l) {
							if (l != j) {
								dp[i + 1][l][0] += dp[i][j][k];
								dp[i + 1][l][0] %= MOD;
							}
							if (l == j && k + 1 < 2) {
								dp[i + 1][l][k + 1] += dp[i][j][k];
								dp[i + 1][l][k + 1] %= MOD;
							}
						}
					}
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 2; j++) {
			ans += dp[n - 1][i][j];
			ans %= MOD;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3068
H,W,K=map(int,input().split())
c=[input() for _ in range(H)]

ans=0
for i in range(1<<H):
    for j in range(1<<W):
        cnt=0
        for h in range(H):
            for w in range(W):
                if c[h][w]=='#':
                    if (i>>h)%2==0 and (j>>w)%2==0:
                        cnt+=1
        if cnt==K:
            ans+=1
print(ans)


Measured memory_bytes: 9220
#include <bits/stdc++.h>
#define i64 long long
#define N (int)(1e5)
using namespace std;
int main() {
	// your code goes here
	string s; cin>>s;
	int freq[26] = {0};
	for(int i=0;i<s.length();i++) freq[s[i]-'a']++;
	
	bool posible = false;
	int i;
	for(i=0;i<26 and !posible;i++) {
		if(freq[i]==0) {
			posible = true;
			break;
		}
	}
	if(!posible) printf("None\n");
	else printf("%c\n", 'a'+i);
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
  int time,total=0,s,m;
  for(int i=0;i<4;i++){
    cin >> time;
    total+=time;
  }
  if(total/60>=1){
    m=total/60;
    total=total%60;
    s=total;
  }
  else{
    s=total;
    m=0;
  }
  cout << m << endl << s << endl;
  return (0);
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
 
using namespace std;
 
typedef unsigned long long ll;
typedef pair<ll, ll> pair_;
 
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
 
int main(){

    ll n, t;
    cin >> n;
    vector<ll> ans_(n, 0);
    vector<ll> a_(n);
    rep(i,n){
        cin >> a_[i];
        ans_[a_[i]-1]++;
    }
    t=0;
    rep(i, n) {
        if(ans_[i]==0) continue;
        else t += ans_[i] * (ans_[i]-1) /2;
    }

    rep(i, n){
        if((ans_[a_[i]-1] == 0)||(ans_[a_[i]-1] == 1)) cout << t << endl;
        else {
            ll as = t;
            as -= ans_[a_[i]-1] * (ans_[a_[i]-1]-1) /2;
            as += (ans_[a_[i]-1] -1)*(ans_[a_[i]-1] -2)/2;
            cout << as  << endl;
        }
    }

 


   
    return 0;
 
}

Measured memory_bytes: 5760
using System;

namespace atcoder_ABC046B
{
    class MainClass
    {
        public static void Main(string[] args)
        {
			string[] array = Console.ReadLine().Split(' ');
			int ballCount = int.Parse(array[0]);
			int colorCount = int.Parse(array[1]);

			int answer = colorCount * (int)Math.Pow((colorCount - 1), (ballCount - 1));
			if (answer == 0)
			{
				Console.WriteLine(2147483647);
			}
			else
			{
				Console.WriteLine(answer);
			}
		}
    }
}

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

int main() {
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
	    cin>>a[i];
	}
	long long ans=0;
	for(int i=1;i<n;i++){
	    if(a[i]>=a[i-1]){
	        continue;
	    }
	    ans+=a[i-1]-a[i];
	    a[i]=a[i-1];
	}
	cout<<ans;
}


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

int main() {
	int X;
	cin >> X;
	bool found = false;

	for (int i = -200; i < 200; i++) {
		for (int j = -200; j < 200; j++) {
			if (pow(i, 5) - pow(j, 5) == X) {
				cout << i << " " << j;
				found = true;
				break;
			}
		}
		if (found) break;
	}
	return 0;
}

Measured memory_bytes: 3564
#include<stdio.h>

int main(void)
{
        int a,b,c,d;
        int i,hajimari,owari,hajima,owa,byousuu;

        scanf("%d%d%d%d",&a,&b,&c,&d);

        if(a<c){
                hajimari = a;
                owari = b;
                hajima = c;
                owa = d;
        }
        else{
                hajimari = c;
                owari = d;
                hajima = a;
                owa = b;
        }

                if(owari<hajima){
                        printf("0\n");
                        return 0;
                }
                else{
                        if(owari>=owa){
                                byousuu = owa - hajima;
                                printf("%d\n",byousuu);
                                return 0;
                        }
                        else{
                                byousuu = owari - hajima;
                                printf("%d\n",byousuu);
                                return 0;
                        }
                }

        return 0;
}


Measured memory_bytes: 128
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=2002;
bitset<maxn*maxn+10>s;
int main()
{
	int N,x,ans;
	while(~scanf("%d",&N)){
		s.reset(); ans=0;
		s[0]=1;
		for(int i=1;i<=N;i++){
			scanf("%d",&x);
			s|=(s<<x);
			ans+=x;
		}
		for(int i=(ans+1)/2;;i++){
			if(s[i]){
		       printf("%d\n",i);
		       break;
		    }
		}
	}
	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

const int MAX = 110000;
int dp[MAX];

int main(){
    int n; cin >> n;
    for(int i = 0; i < MAX; ++i) dp[i] = n;
    dp[0] = 0;
    //dp[i]を計算
    for(int i = 1; i <= n; ++i){
        for(int pow6 = 1; pow6 <= i; pow6 *= 6) dp[i] = min(dp[i],dp[i-pow6] + 1);
        for(int pow9 = 1; pow9 <= i; pow9 *= 9) dp[i] = min(dp[i],dp[i-pow9] + 1);
    }
    cout << dp[n] << endl;
}

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

int countABC(int num, string str);

int main() {
	int num = 0;
	string str;

	cin >> num;
	cin >> str;

	cout << countABC(num, str) << endl;

	return 0;
}

int countABC(int num, string str) {
	int count = 0;

	for (int i = 0; i <= (num - 3); i++) {
		if(str[i] == 'A' && str[i + 1] == 'B' && str[i + 2] == 'C') {
			count++;
		}
	}

	return count;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> d(n);
	for(int i=0; i<n; i++){
		cin >> d.at(i);
	}
	long long sum = 0;
	for(int i=1; i<n; i++){
		sum += d.at(i);
	}
	long long ans = 0;
	for(int i=0; i<n-1; i++){
		ans += d.at(i)*sum;
		sum -= d.at(i+1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm> 
#include<cstring>
#define LL long long
#define lc(x) x<<1
#define rc(x) x<<1|1
using namespace std;
const int N=3e5+5;
int w,h,n,ans,L,R;
int mx[N*4],tag[N*4];
struct node{int x,y;node(int _x=0,int _y=0):x(_x),y(_y){};}p[N],a[N],b[N]; 
int read()
{
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
void modify(int x,int l,int r,int v)
{
    if(L<=l&&r<=R){mx[x]+=v;tag[x]+=v;return;}
    int mid=(l+r)>>1;
    if(L<=mid)modify(lc(x),l,mid,v);
    if(R>mid)modify(rc(x),mid+1,r,v);
    mx[x]=max(mx[lc(x)],mx[rc(x)])+tag[x];
}
bool cmp(node a,node b){return a.x<b.x||(a.x==b.x&&a.y<b.y);}
void work()
{
    memset(mx,0,sizeof(mx));
    memset(tag,0,sizeof(tag));
    sort(p+1,p+n+1,cmp);
    int l=0,r=0;
    for(int i=1;i<=n-1;i++)
    {
        if(p[i].y<=h/2)
        {
            int nxt=i-1;
            while(l&&a[l].y<p[i].y)
            {
                L=a[l].x;R=nxt;nxt=a[l].x-1;
                modify(1,1,n,a[l].y-p[i].y);l--; 
            }
            if(nxt!=i-1)a[++l]=node(nxt+1,p[i].y);
        }
        else
        {
            int nxt=i-1;
            while(r&&b[r].y>p[i].y)
            {
                L=b[r].x;R=nxt;nxt=b[r].x-1;
                modify(1,1,n,p[i].y-b[r].y);r--;
            }
            if(nxt!=i-1)b[++r]=node(nxt+1,p[i].y);
        }
        a[++l]=node(i,0);b[++r]=node(i,h);
        L=i;R=i;modify(1,1,n,h-p[i].x);
        ans=max(ans,mx[1]+p[i+1].x);
    }
}
int main()
{
    w=read();h=read();n=read();
    for(int i=1;i<=n;i++)p[i].x=read(),p[i].y=read();
    p[++n]=node(0,0);p[++n]=node(w,h);work();
    for(int i=1;i<=n;i++)swap(p[i].x,p[i].y);
    swap(w,h);work();
    printf("%d",ans*2);
    return 0;
}

Measured memory_bytes: 16640
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] arg) {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			int M = sc.nextInt();
			int A = sc.nextInt();
			Seg[] segs = new Seg[M];
			for (int i = 0; i < M; ++i) {
				int h = sc.nextInt();
				int p = sc.nextInt();
				int q = sc.nextInt();
				segs[i] = new Seg(h, p, q);
			}
			Arrays.sort(segs);
			for (int i = 0; i < M; ++i) {
				Seg s = segs[i];
				if (s.p == A) {
					A = s.q;
				} else if (s.q == A) {
					A = s.p;
				}
			}
			System.out.println(A);
		}
	}

	static class Seg implements Comparable<Seg> {
		int h, p, q;

		public Seg(int h, int p, int q) {
			this.h = h;
			this.p = p;
			this.q = q;
		}

		public int compareTo(Seg o) {
			return o.h - this.h;
		}
	}

}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  long long k;
  cin >> s >> k;
  for (int i = 0; i < min((long long)s.size(), k); i++) {
    if (s.at(i) != '1') {
      cout << s.at(i) << '\n';
      return 0;
    }
  }
  cout << 1 << '\n';
}


Measured memory_bytes: 256
l=[0,0,0,0]
for i in range(3):
    a,b=list(map(int,input().split(" ")))
    l[a-1]+=1
    l[b-1]+=1
if l.count(1)+l.count(3) not in [0,2]:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <string.h>
#include <math.h>

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

int main(void)
{
	double x1, y1, x2, y2,ans;

	cin >> x1 >> y1 >> x2 >> y2;

	ans= sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
	cout << fixed << setprecision(10) << ans << endl;
}



Measured memory_bytes: 3264
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){
    int h,w;
    cin >> h >> w;
    vector<string> map(h);
    for(int i = 0; i < h; i++){
        cin >> map[i];
    }
    string chk(w,'.');
    vector<int> check1(h,0);
    for(auto itr = map.begin(); itr != map.end(); itr++){
        if(chk == *itr){
            check1[itr-map.begin()] = 1;
        }
    }
    vector<int> check(w,0);
    for(int i = 0; i < w; i++){
        int j = 0;
        while(j < h&&map[j][i] == '.')
            j++;
        if(j == h){
            check[i] = 1;
        }
    }
    for(int i = 0; i < h; i++){
        if(check1[i] == 1)
            continue;
        for(int j = 0; j < w; j++){
            if(check[j] == 1){
                continue;
            }
            else
                cout << map[i][j];
        }
        cout << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define MAXN 200005
#define MOD 1000000007
using namespace std;

long long n, k, prefix[MAXN], suffix[MAXN], ans[MAXN];

int main() {
	cin >> n >> k;
	suffix[1] = n;
	for (long long i=2; i<=n; i++) {
		prefix[i] = prefix[i - 1] + i - 1;
		suffix[i] = suffix[i - 1] + n - i + 1;
		prefix[i] %= MOD; suffix[i] %= MOD;
	}
	ans[n + 1] = 1;
	for (long long i=n; i>=1; i--) {
		ans[i] = ans[i + 1] + suffix[i] - prefix[i] + 1;
		ans[i] = (ans[i] + MOD) % MOD;
	}
	cout << ans[k] << "\n";
}

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



int main(void)
{
	string s;
	cin >> s;
	if (s.size() == 3) {
		for (int i = s.size()-1; i >= 0; i--)
			cout << s[i];
		cout << "\n";
	}
	else {
		cout << s << "\n";
	}

    return 0;
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	bool b = true;
	while (n) {
		if (n % 10 == 7)
			b = false;
		n /= 10;
	}
	cout << (b ? "No" : "Yes");
	cin >> n;
}

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

int main() {
    ll a;
    double b;
    cin >> a >> b;
    ll bn = b * 100 + 0.1;
    a *= bn;
    a /= 100;
    cout << a << endl;
}

Measured memory_bytes: 3724
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int k; cin >> k;
    string s; cin >> s;
    if (s.size() <= k) {
        cout << s << endl;
    } else {
        rep(i,k) {
            cout << s[i];
        }
        cout << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
/*
      author : nishi5451
      created: 11.08.2020 00:19:21
*/

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


int main(){
    int n;
    cin >> n;
    int ans;
    ans = 800*n - 200*(n/15);
  	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
import Data.List
import Data.Ord

solve :: [Int] -> (Int,Int) -> (Int,Int)
solve [] (a,b) = (a,b)
solve [x] (a,b) = (a,b)
solve (x:y:xs) (a,b) 
    | a * b /= 0 = (a,b)
    | x /= y = solve (y:xs) (a,b)
    | x == y && a == 0 = solve xs (x,b)
    | x == y && b == 0 = solve xs (a,x) 

main = do
    getLine 
    xs <- sortBy (comparing Down) . map read . words <$> getLine :: IO [Int]
    let (a,b) = solve xs (0,0)
    print $ if a*b == 0 then 0 else a*b

Measured memory_bytes: 52604
#include<bits/stdc++.h>
using namespace std;
const int N=101000;
const int K=20;
double EPS=1e-7;
typedef long long ll;

map<string,int> mp;


int32_t main()	
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
 	string s;
 	int n;
 	cin>>n>>s;
 	for (int i = 0; i < s.size(); ++i)
 	{
 		for (int j = 0; j < n; ++j)
 		{
 			if(s[i]=='Z')
 				s[i]='A';
 			else
 				s[i]++;
 		}
 	}
 	cout<<s<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;
const int Inf = 1 << 30;

int main()
{
	int a,b,h;
	while(~scanf("%d%d%d",&a,&b,&h)){
		printf("%d\n",(a + b) * h / 2);
	}
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int elements = sc.nextInt();
        int[] value = new int[elements];
        for (int i = 0; i < elements; i++) {
            value[i] = sc.nextInt();
        }
        solve(value);
    }

    public static void solve(int[] height){
        int result = 0;
        int now = 0;
        for(int i=1; i<height.length; i++){
            if(height[i-1]>=height[i]){
                now++;
            }else{
                if(result<now) result = now;
                now = 0;
            }
        }
        if(result<now) result = now;
        System.out.println(result);
    }
}

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

int main(){
  int N;
  cin >> N;
  bool ans = false;
  for(int i=9; i>=1; i--){
    if(N %i == 0){
      int x = N/i;
      if(x <= 9){
        ans = true;
      }
    }
  }
  if(ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

int main()
{
  int N, M;
  pair<int,int> a[51];
  int res[51];
  cin >> N>>M;

  rep(i,M) {
    int aa,bb;
    cin >> aa>>bb;
    a[i] = make_pair(--aa,--bb);

  }

  rep(i,N) res[i]=0;

  rep(i,M){
    res[a[i].first]++;
    res[a[i].second]++;
  }

  rep(i,N) {
    cout << res[i] << endl;
  }

}

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

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }

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

  string w[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  rep(i,7){
    if(s == w[i]){
      cout << (7 - i) << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
// Bismillahir Rahmanir Rahim
// AtCoder-

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

int main(){
 string s;  cin>>s;
 for(int i = 0; i < s.size(); ++i){
 	if(s[i]=='7'){
	 cout<<"Yes\n";
	 return 0;
}
}
 cout<<"No\n";
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<queue>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define INF 1000000007
#define MOD 1000000007
#define MAX_N 105
#define MAX_W 100005

ll dp[MAX_N][MAX_W];//0:海,1:山,2:宿題,dp[i][j] = iをj日目に行う時の幸福度
ll weight[MAX_N];
ll value[MAX_N];

int main(){

    ll n,weight_maxi;
    cin >> n >> weight_maxi;
    REP(i,n){
        cin >> weight[i] >> value[i];
    }

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

            if(j < weight[i-1]){
                dp[i][j] = dp[i-1][j];
            }else{
                dp[i][j] = max(dp[i-1][j],dp[i-1][j-weight[i-1]]+value[i-1]);
            }
        }
    }
    cout << dp[n][weight_maxi] << endl;


    return 0;
}


Measured memory_bytes: 79360
class DisjointSetUnion:
    def __init__(self, n):
        self.n = n
        self.par = [-1] * n
        self.rank = [0] * n

    def root(self, x):
        if self.par[x] == -1:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            x, y = y, x
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1
        self.par[y] = x
        return

if __name__ == '__main__':
    n, q = map(int, input().split())
    dsu = DisjointSetUnion(n)

    for i in range(q):
        t, u, v = map(int, input().split())

        if t:
            print(int(dsu.same(u, v)))
        else:
            dsu.unite(u, v)


Measured memory_bytes: 12960