akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		Integer[] a = new Integer[n];

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		int count = 0;
		boolean b = true;

		while (b) {

			for (int j = 0; j < a.length; j++) {

				if (a[j] % 2 > 0) {
					b = false;
					break;

				} else {

					a[j] = a[j] / 2;
				}
			}

			if (b) {
				// カウントアップ
				count++;
			}
		}

		// 出力
		System.out.println(count);
	}
}

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

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

  int n, d;
  cin >> n >> d;
  vector<vector<int>> v(n, vector<int>(d));
  rep(i, 0, n) { rep(j, 0, d) cin >> v[i][j]; }

  int ans = 0;
  rep(i, 0, n) {
    rep(j, i + 1, n) {
      int sum_val = 0;
      rep(k, 0, d) {
        int t = v[i][k] - v[j][k];
        sum_val += (t * t);
      }
      double v = sqrt(sum_val);
      if (floor(v) == v) ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int N,D,X;

	scanf("%d %d %d",&N,&D,&X);

	int ans = X;
	int tmp;

	for(int loop = 0; loop < N; loop++){

		scanf("%d",&tmp);
		ans += (D-1)/tmp+1;
	}

	printf("%d\n",ans);

	return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,n,i;
	long long a;
    t = 1;
    while(t--) {
     a = 0;
	 cin >> n;
	 int arr[n + 1],brr[n];
	 for(i = 0; i < n + 1; i++) {
	  cin >> arr[i];
	  a = a + arr[i];
     }
     for(i = 0; i < n; i++)
      cin >> brr[i];
	 for(i = 0; i < n; i++) {
	  if(arr[i] <= brr[i]) {
	   brr[i] = brr[i] - arr[i];
	   arr[i] = 0;
      }
      else {
       arr[i] = arr[i] - brr[i];
       brr[i] = 0;
	  }
	  if(arr[i + 1] <= brr[i]) {
	   brr[i] = brr[i] - arr[i + 1];
	   arr[i + 1] = 0;
      }
      else {
       arr[i + 1] = arr[i + 1] - brr[i];
       brr[i] = 0;
	  }
	 }
	 for(i = 0; i < n + 1; i++) {
	  if(arr[i] > 0)
	   a = a - arr[i];
	 }
	 cout << a << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int A[23000000]; 
long long MOD = 1000000007; 
long long power(long long a, int n){
	long long ans = 1; long long mul = a;
	while(n){
		if(n & 1){
			ans *= mul; ans %= MOD;
		}
		n >>= 1;
		mul = mul * mul % MOD;
	}
	return ans;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int S; cin >> S;
	long long ans = 0;
	for(int i = 1; i < 10; i++) A[i] = 1;
	for(int i = 10; i < 100; i++) A[i] = 2;
	for(int i = 100; i < 1000; i++) A[i] = 3;
	for(int i = 1000; i < 10000; i++) A[i] = 4;
	for(int i = 10000; i < 100000; i++) A[i] = 5; 
	for(int i = 100000; i < 1000000; i++) A[i] = 6;
	for(int i = 1000000; i < 10000000; i++) A[i] = 7;
	for(int i = 10000000; i < 23000000; i++) A[i] = 8;
	int now = 0; int r = 0; 
	for(int i = 1; i < 10000000; i++){
		while(now < S){
			r++; now += A[r]; 
		}
		if(now == S) ans ++; 
		now -= A[i]; 
	}
	vector<int> div; 
	for(int i = 1; i * i <= S; i++){
		if(S % i != 0) continue; 
		div.push_back(i); 
		if(i * i != S) div.push_back(S/i); 
	}
	for(int i : div){
		if(i < 8) continue; 
		long long tmp = (MOD + power(10, i - 1) * 9 + 1 - S/i) % MOD; 
		ans += tmp; ans %= MOD; 
	}
	long long add = 0; 
	for(int d = 8; d <= S; d++){
		int mx = S / d - S % d; 
		if(mx <= 0) continue; 
		int tmp = mx / (d+1) + 1; 
		if(S % (d+1) == 0) tmp--; 
		if(S % d == 0) tmp --; 
		add += tmp; 
	}
	add %= MOD; 
	ans += add; ans %= MOD; 
	cout << ans << "\n"; 
}

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

using namespace std;

const int Nmax = 1e5 + 10;

typedef long long ll;

int n;
ll a[Nmax];
bool check;
ll side1, side2;

int32_t main(){
    cin >> n;
    for(int i = 1; i <= n; ++i) cin >> a[i];
    sort(a + 1, a + n + 1);
    for(int i = n-1; i >= 1; --i){
        if(a[i] == a[i+1]){
            if(!check) { check = true, side1 = a[i], i--; continue; }
            if(check) { side2 = a[i]; break; }
        }
    }
    cout << side1 * side2;
}


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

int main(){
    int n,x,count;

    while (1){
        count=0;
        cin >> n >> x;
        
        if(n==0 && x==0){
            break;
        }

        for(int a=1;a<=(n-2);a++){
            for(int b=a+1;b<=(n-1);b++){
                for(int c=b+1;c<=n;c++){
                    if(x==a+b+c){
                        count+=1;
                    }
                }
            }   
        }

        cout << count << endl;
    }
    

    return 0;
}




Measured memory_bytes: 3076
import java.util.Scanner;


public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		double[] x = new double[6];
		double[] y = new double[2];
		while (scan.hasNext()) {
			for (int i = 0; i < x.length; i++) {
				x[i] = scan.nextDouble();
			}
			double det = x[0] * x[4] - x[1] * x[3];
			y[0] = (x[4] * x[2] - x[1] * x[5]) / det;
			y[1] = (x[0] * x[5] - x[2] * x[3]) / det;
			if (y[0] == 0) {
				y[0] = 0;
			}
			if (y[1] == 0) {
				y[1] = 0;
			}
			System.out.printf("%.3f %.3f\n", y[0], y[1]);
		}
	}

}

Measured memory_bytes: 20676
import collections
import itertools
import sys


def getint(): return int(input())
def getints(): return list(map(int, input().split()))

n=getint()

values=[getints() for _ in range(n)]

check = []
for h in values:
    if h[2] > 0:
        check = h
        break

check_x, check_y, check_h = check

for cx in range(101):
    for cy in range(101):
        H = check_h + abs(check_x - cx) + abs(check_y - cy)
        ok = True
        for x,y,h in values:
            h_prime = max(0, H - abs(x-cx) - abs(y-cy))
            if h_prime != h:
                ok = False
                break
        if ok:
            print(cx,cy,H)
            sys.exit(0)


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include<climits>
#include <string>
#include <map>
#include <set>
#include <list>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

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


float N,T,A,H[1010];
int ans,i, j;
int main(){
    scanf("%f%f%f",&N,&T,&A);
    fornum(i,0,N){
        scanf("%f", &H[i]);
        H[i] = T - H[i] * 0.006;
        H[i] = A > H[i] ? A - H[i] : H[i] - A;
        ans = H[i] < H[ans] ? i : ans;
    }
    printf("%d\n", ans + 1);

    return 0;
}

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

int main() {
    char str[201], temp[201];
    int m, h, len, j;
    while (1) {
        scanf("%s", str);           // 文字列
        len = strlen(str);
        if (*str == '-') {break;}   // 入力終了
        scanf("%d", &m);            // シャッフル回数
        for (int i=0; i<m; i++) {
            *temp = '\0';
            scanf("%d", &h);
            strcpy(temp, str);      // tempにstrをコピー
            *str = '\0';
            for (j=0; j<(len-h); j++) {
                str[j] = temp[h+j];
            }
            str[j] = '\0';
            temp[h] = '\0';
            strcat(str, temp);
        }
        printf("%s\n", str);
    }
    return 0;
}


Measured memory_bytes: 2068
#include <stdio.h>
#include <stdlib.h>

#define INF  10000000000000

int search(long key, long v[], int n)
{
  long l = 0;
  long r = n - 1;
  long i;
  while (r - l >= 1) {
    i = (l + r) / 2;
    if (key > v[i])
      l = i + 1;
    else
      r = i;
  }
  if (key  > v[i])
    return i + 1;
  else
    return i;
}

long min3(long a, long b, long c)
{
  long min = a;

  if (b < min) min = b;
  if (c < min) min = c;
  return min;
}      
  
int main(void)
{
  int a, b, q;
  long s[100002];
  long t[100002];
  long x[100000];
  int c, d;

  scanf("%d %d %d", &a, &b, &q);
  s[0] = -INF;   s[a + 1] = INF;
  t[0] = -INF;   t[b + 1] = INF;
  for (int i = 1; i <= a; i++) 
    scanf("%ld", &s[i]);
  for (int i = 1; i <= b; i++)
    scanf("%ld", &t[i]);
  for (int i = 0; i < q; i++) 
    scanf("%ld", &x[i]);
    
  for (int i = 0; i < q; i++) {
    c = search(x[i], s, a + 2);
    d = search(x[i], t, b + 2);
    long res = INF;
    for (int j = c - 1; j <= c; j++) {
      for (int k = d - 1; k <= d; k++) {
	long d1 = labs(s[j] - x[i]) + labs(t[k] - s[j]);
	long d2 = labs(t[k] - x[i]) + labs(s[j] - t[k]);
	res = min3(res, d1, d2);
      }
    }
    printf("%ld\n", res);
  }
  
  return 0;
}


Measured memory_bytes: 3584
#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 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 h, w; std::cin >> h >> w;
  vector<string> grid(h); rep(i, h) std::cin >> grid[i];
  rep(y, h) rep(x, w) {
    if (grid[y][x] == '.') continue;
    bool ok = false;
    srep(dy, -1, 2) srep(dx, -1, 2) if (dy*dy+dx*dx==1) {
      int ny = y+dy, nx = x+dx;
      if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
      if (grid[ny][nx] == grid[y][x]) ok = true;
    }
    if (!ok) {
      std::cout << "No" << "\n";
      return 0;
    }
  }
  std::cout << "Yes" << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100005
#define INF 0x7fffffff
using namespace std;
int n,js,a[N],s[N],c[N];
long long res,num;
void merge_sort(int l,int r) {
	int mid=(l+r)>>1;
	for(register int k=l,i=l,j=mid+1; k<=r; ++k)
		if(j>r||(i<=mid&&s[i]<=s[j])) c[k]=s[i++];
		else c[k]=s[j++];
	for(register int k=l; k<=r; ++k) s[k]=c[k];
}
void work(int l,int r) {
	if(l==r) return;
	int mid=(l+r)>>1;
	work(l,mid),work(mid+1,r);
	for(register int i=l,j=mid+1; j<=r; ++j) {
		while(i<=mid&&s[i]<=s[j]) ++i;
		res+=i-l;
	}
	merge_sort(l,r);
}
int check(int x) {
	for(register int i=1; i<=n; ++i) s[i]=s[i-1]+(a[i]>=x?1:-1);
	res=0,work(0,n);
	return res>=(num+1)/2;
}
int main() {
//	freopen("median.in","r",stdin);
//	freopen("median.out","w",stdout);
	int l=INF,r=0,ans;
	scanf("%d",&n);
	num=1LL*n*(n-1)/2+n;
	for(register int i=1; i<=n; ++i)
		scanf("%d",&a[i]),l=min(a[i],l),r=max(a[i],r);
	while(l<=r) {
		int mid=(l+r)>>1;
		if(check(mid)) ans=mid,l=mid+1;
		else r=mid-1;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;
// Comment out below and program paste

// #include "UnionFind.hpp"
// #include "power.hpp"

class dice {
    private:
    vector<int> face;
    int back = 6;

    vector<vector<int>> apper = {
        {-1, 5, -1},
        {4, 1, 3},
        {-1, 2, -1},
    };
    public:
    void input() {
        face.push_back(0);
        for (int i = 0; i < 6; i++) {
            int temp;
            cin >> temp;
            face.push_back(temp);
        }
    }

    void rotation(char S) {
        if (S == 'S') {
            int temp = apper[2][1];
            apper[2][1] = apper[1][1];
            apper[1][1] = apper[0][1];
            apper[0][1] = back;
            back = temp;
        } else if (S == 'W') {
            int temp = apper[1][0];
            apper[1][0] = apper[1][1];
            apper[1][1] = apper[1][2];
            apper[1][2] = back;
            back = temp;
        } else if (S == 'N') {
            int temp = apper[0][1];
            apper[0][1] = apper[1][1];
            apper[1][1] = apper[2][1];
            apper[2][1] = back;
            back = temp;
        } else {
            int temp = apper[1][2];
            apper[1][2] = apper[1][1];
            apper[1][1] = apper[1][0];
            apper[1][0] = back;
            back = temp;
        }
        // cout << back << endl;
    }

    int result() {
        return face[apper[1][1]];
    }
};


signed main() {
    dice dice_one;
    dice_one.input();
    string S;
    cin >> S;
    for (int i = 0; i < S.length(); i++) {
        dice_one.rotation(S[i]);
    }
    cout << dice_one.result() << endl;
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
typedef pair<ll, l_l> lll;
ll N, M, X;
ll U[2000], V[2000], W[2000];
vector<lll> edges;

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<ll> Size;
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n + 1); rank.resize(n + 1); Size.resize(n + 1);
        for (int i = 0; i <= n; ++i) par[i] = i, rank[i] = 0, Size[i] = 1;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        Size[x] += Size[y];
        return true;
    }

    ll size(int x){
        return Size[root(x)];
    }
};

ll beki(ll a, ll b) {
    if(b == 0) return 1;
    ll ret = beki(a, b / 2);
    ret = ret * ret % mod;
    if(b & 1) ret = ret * a % mod;
    return ret;
}

ll num[3];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M >> X;
    for(int i = 0; i < M; i++) {
        cin >> U[i] >> V[i] >> W[i];
        U[i]--;
        V[i]--;
        edges.push_back({W[i], {U[i], V[i]}});
    }
    sort(edges.begin(), edges.end());
    for(int i = 0; i < M; i++) {
        ll score = 0;
        UnionFind uni(N);
        uni.merge(U[i], V[i]);
        score += W[i];
        for(auto e : edges) {
            if(uni.merge(e.second.first, e.second.second)) {
                score += e.first;
            }
        }
        if(score < X) num[0]++;
        if(score == X) num[1]++;
        if(score > X) num[2]++;
    }
    cerr << num[0] << " " << num[1] << " " << num[2] << endl;
    ll ans;
    if(num[0] != 0) {
        ans = beki(2, num[1]) - 1;
        ans %= mod;
        ans *= beki(2, num[2]);
        ans %= mod;
        ans *= 2;
        ans %= mod;
    } else if(num[1] != 0) {
        ans = beki(2, num[1]) - 2;
        ans *= beki(2, num[2]);
        ans %= mod;
    } else {
        ans = 0;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
from collections import deque
import sys

input = sys.stdin.readline

sys.setrecursionlimit(10 ** 6)

n, m = map(int, input().split())

if m & 1:
    print(-1)
    exit()

g = [set() for _ in range(n + 1)]
for _ in range(m):
    a, b = map(int, input().split())
    g[a].add(b)
    g[b].add(a)

seen = [False] * (n + 1)
seen[1] = True

mst = [set() for _ in range(n + 1)]

dq = deque()
dq.append(1)

while dq:
    v = dq.popleft()

    for u in g[v]:
        if seen[u]:
            continue
        seen[u] = True

        mst[u].add(v)
        mst[v].add(u)

        dq.append(u)

ans = set()
deg = [0] * (n + 1)
for v in range(1, n + 1):
    for u in g[v]:
        if v > u: continue
        if u not in mst[v]:
            ans.add((u, v))
            deg[u] += 1


def dfs(v, pr):
    for u in mst[v]:
        if u == pr:
            continue
        dfs(u, v)

    if pr == -1:
        return

    if deg[v] % 2 == 0:
        ans.add((pr, v))
        deg[pr] += 1
    else:
        ans.add((v, pr))
        deg[v] += 1


dfs(1, -1)

for aa in ans:
    print(*aa)


Measured memory_bytes: 111852
#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

// #define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline void chmax(T& a,T const& b){a=max(a,b);}
template<class T> inline void chmin(T& a,T const& b){a=min(a,b);}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60; 
const int MAX_N = 200005;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  vi a(N); rep(i,N) cin >> a[i];
  vi b = a;
  sort(ALL(b));
  int l = b[N/2-1];
  int r = b[N/2];
  rep(i,N){
    if(a[i]<=l) cout << r << endl;
    else cout << l << endl;
  }
  return 0;
}

Measured memory_bytes: 3840
#include<iostream>
#define MAX_N 1000000
using namespace std;

bool prime[MAX_N];

void ini()
{
	for (int i = 2; i < MAX_N; i++)
	{
		if (prime[i])
			continue;
		else
		{
			for (int j = i * 2; j < MAX_N; j += i)
			{
				if (!prime[j] && j%i == 0)
					prime[j] = true;
			}
		}
	}
}

void solve()
{
	int ans, num;
	while (cin >> num)
	{
		ans = 0;
		for (int i = 2; i <= num; i++)
			if (!prime[i])
				ans++;
		cout << ans << endl;
	}
}

int main()
{
	ini();
	solve();
	return 0;
}

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

int main() 
{ 
   	int n , k;
   	cin >> n ;
   	map< int , int > mp;
   	for(int i = 1 ; i <= n ; i++){
   		int x;
   		cin >> x;
   		mp[x] = i;
   	}
   	for(auto i : mp){
   		cout << i.second << " ";
   	}
	return 0; 
} 

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  int sum=0;
  for(int i=1;i<=N;i++){
  int A;
    cin>>A;
    if(A!=i)
      sum++;
  }
  if(sum<=2)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <string>
#include <stdlib.h>
#include <algorithm>
 
using namespace std;
 
int ascSort(const void* v1, const void* v2) {
    const int _v1 = *((const int*)v1);
    const int _v2 = *((const int*)v2);
 
    if ( _v1 < _v2 ) {
        return 1;
    } else if ( _v1 > _v2 ) {
        return -1;
    } else {
        return 0;
    }
}
int main(){
	long int n,i,look,start,end,check,ans=0;
	string get,getrep;
	cin >> n;
	cout << ans << endl;
	cin >> get;
	start = 0;
	look = n/2;
	end = n;
	for(i=1;i<=20;i++){
		cout << look <<endl;
		cin >> getrep;
		if(getrep == "Vacant"){
			break;
		}else if((look%2==0 && get == getrep) || (look%2==1 && get != getrep)){
			start = look;
			look = (start +end)/2;
		}else{
			end = look;
			look = (start+end)/2;
		}
	}
	return 0;
}

Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	int X, A;
	cin >> X >> A;
	if(X < A)
	cout << 0 << endl;
	else
	cout << 10 << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


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


int main()
{
  std::vector<int> v(5);
  for(int i=0; i<5; i++)
  {
    cin >> v[i];
  }
  int k;
  cin >> k;
  for(int i=0; i<5; i++)
  {
    for(int j=i; j<5; j++)
    {
      if(v[j]-v[i]>k){
        cout << ":(" << endl;
        return 0;
      }
    }
  }
  cout << "Yay!" << endl;
  return 0;
}


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

int main(int argc, char const *argv[])
{
	string s; cin >> s;
	int cnt = 0;
	for (auto u : s) {
		if (u == 'x') cnt++;
	}
	if (cnt > 7) printf("NO\n");
	else printf("YES\n");
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math
a, b, h, m = map(int, input().split())
h = 30*h
m = 6*m
h += m/12
delta = abs((h-m)*math.pi/180)
print(math.sqrt(a**2+b**2-2*a*b*math.cos(delta)))

Measured memory_bytes: 9180
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
//　20min
int main(void){
  int n;
  int ans = 0;

  scanf("%d", &n);

  for(int i = 1; i <= n; i = i+2){
    int cnt = 0;
    for(int j = 1; j <= i; j++){
      if(i % j == 0){
	cnt++;
      }
    }
    if(cnt == 8){
      ans++;
    }
  }
  
  printf("%d\n", ans);
  
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> mp;
  ll sum = 0;
  rep(i, n) {
    cin >> a[i];
    sum += a[i];
    mp[a[i]-1]++;
  }
  int q;
  cin >> q;
  rep(i, q) {
    ll b, c;
    cin >> b >> c;
    int bi = b - 1;
    int ci = c - 1;
    if(mp.count(bi)) {
      sum -= b * mp[bi];
      sum += c * mp[bi];
      mp[ci] += mp[bi];
      mp[bi] = 0;
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 7480
import sys
readline = sys.stdin.readline

# 0-indexでやる

D = int(readline())
C = list(map(int,readline().split())) # 満足度の下がりやすさ
S = [None] * D
sortS = [None] * D
for i in range(D):
  s = list(map(int,readline().split()))
  S[i] = s.copy()
  for j in range(len(s)):
    s[j] = (s[j],j)
  sortS[i] = sorted(s, key = lambda x:x[0], reverse = True)

def make_ans(D,C,limiter = 52, threshold = 42, balance = 0.8):
  ans = []
  last_submit = [0] * 26
  for i in range(D):
    info = sortS[i]
    
    # limiter回以上提出がないものがあれば、threshold回を超えたもののうちCの値が高いものを提出
    if i - min(last_submit) >= limiter:
      ind = -1
      for j in range(len(last_submit)):
        if i - last_submit[j] >= threshold:
          if ind == -1:
            ind = j
          else:
            if C[ind] < C[j]:
              ind = j
      ans += [ind]
      last_submit[ind] = i
      continue
      
    topval = info[0][0]
    for j in range(len(info)):
      val = info[j][0]
      if val < topval * (balance):
        continue # 最高値の半分になるのであればやめよう
      index = info[j][1]
      if i - last_submit[index] < 26:
        continue
      ans += [index]
      last_submit[index] = i
      break
    else:
      ans += [info[0][1]]
  return ans

def calc_score(arr):
  point = 0
  last_submit = [0] * 26
  for i in range(len(arr)):
    # i日目
    point += S[i][arr[i]]
    for j in range(len(last_submit)):
      point -= (i - last_submit[j]) * C[j]
  return point
      
ans = make_ans(D,C)
#print(ans)
from collections import defaultdict
#used_limiter = defaultdict(int)
#used_threshold = defaultdict(int)
#used_balance = defaultdict(int)

best = calc_score(ans)
for limiter in range(40,62):
  for threshold in range(36, limiter):
    for balance in (0.75,0.8,0.85):
      new_ans = make_ans(D,C,limiter,threshold,balance)
      new_score = calc_score(new_ans)
      if new_score > best:
        ans = new_ans
        best = new_score
        
#        used_limiter[limiter] += 1
#        used_threshold[threshold] += 1
#        used_balance[balance] += 1
  
def show(arr):
  for a in arr:
    print(a + 1)

#print(used_limiter)
#print(used_threshold)
#print(used_balance)

show(ans)

Measured memory_bytes: 10312
#include<bits/stdc++.h>
using namespace std;
#define str string
#define rep(x) for(int y=0;y<x;y++)
#define all(x) begin(x),end(x)
int main(){
    int A,B;
    vector<char>s(19);
    rep(19){
        cin>>s.at(y);
        if(y==5||y==13)cout<<' ';
        else cout<<s.at(y);
    }
}


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

bool cells[502][502];
int lft[502][502];

int main() {
    int H, W;
    while (cin >> H >> W, H) {
        char c;
        for (int i=1; i<=H; ++i) {
            for (int j=1; j<=W; ++j) {
                cin >> c;
                cells[i][j] = c == '*';
            }
        }
        for (int i=1; i<=H; ++i) {
            for (int j=1; j<=W; ++j) {
                if (cells[i][j]) {
                    lft[i][j] = 0;
                } else {
                    lft[i][j] = lft[i][j-1] + 1;
                }
            }
        }
        int ans = 0;
        for (int i=1; i<=H; ++i) {
            for (int j=1; j<=W; ++j) {
                int area = 0;
                int wid = 501;
                for (int k=i; k<=H; ++k) {
                    if (cells[k][j]) break;
                    wid = min(wid, lft[k][j]);
                    area = max(area, wid * (k - i + 1));
                }
                ans = max(ans, area);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2388
import sys
input = sys.stdin.readline

N, = map(int, input().split())
L = [int(v) for v in input().split()]

def gcd(x, y):
    if x < y:
        x, y = y, x
    if x % y == 0:
        return y
    return gcd(y, x % y)

l1 = [None] * N
l2 = [None] * N

l1[0] = L[0]
for i in range(1, N):
    l1[i] = gcd(L[i], l1[i - 1])
    
l2[-1] = L[-1]
for i in reversed(range(N - 1)):
    l2[i] = gcd(L[i], l2[i + 1])
    
ans = 1
for i in range(N):
    if i == 0:
        ans = max(ans, l2[1])
    elif i == N - 1:
        ans = max(ans, l1[-2])
    else:
        ans = max(ans, gcd(l1[i - 1], l2[i + 1]))
        
print(ans)

Measured memory_bytes: 14456
N = input()
S = input()
count = 0
for i in range(1000):
    n = "{:03d}".format(i)
    n1, n2, n3 = n[0], n[1], n[2]
    i1 = S.find(n1)
    if -1 < i1 < len(S) - 2:
        S1 = S[i1 + 1:]
        i2 = S1.find(n2)
        if -1 < i2 < len(S1) - 1:
            S2 = S1[i2 + 1:]
            i3 = S2.find(n3)
            if -1 < i3:
                count += 1
                continue
print(count)


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <regex>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;
    string r = "^\\d{" + to_string(a) + "}[-]\\d{" + to_string(b) +"}$";
    regex re(r);
    if (regex_match(s, re)) {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const ll mask = 0xAAAAAAAA;
int n, ans;
vector<vi> e;
ll rec(int c, int p){
	ll s = 0, t = 0;
	for(int i : e[c]) if(i != p){
		ll x = rec(i, c);
		s |= x;
		t += x;
		t &= ~((t & mask) >> 1);
	}
	t &= mask;
	int l = t ? 64 - __builtin_clzll(t) : 0;
	l = __builtin_ctzll((s | (s & ~mask) << 1 | (1ll << l) - 1) + 1);
	
	ans = max(ans, l / 2);
	s |= 1ll <<l;
	s &= ~((1ll << l) - 1);
	return s;
}
int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	cin >> n;
	e.resize(n);
	rep(i, n - 1){
		int a, b; cin >> a >> b; a--; b--;
		e[a].pb(b);
		e[b].pb(a);
	}
	rec(0, 0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mod 1000000007
const int N=200005;
double PI = 3.14159265;

bool f(double ang, double base, double b, double filled) {
    ang = (ang * PI) / 180 ;
    double s_ang,c_ang;
    s_ang=sin(ang);
    c_ang=cos(ang);
    double hyp=abs(base/c_ang);
    double ht=abs(hyp*s_ang);
    double bf=abs(b-filled);
    //cout<<ht<<" "<<c_ang<<endl;
    if(ht+filled>b){
        return 0;
    }
    return 1;
}
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif*/
    cout<<fixed<<setprecision(15);
    
    
    double a,b,x;
    cin>>a>>b>>x;

    double l=0.0;
    double filled=x/(a*a);
    double r=90.0;
    //cout<<filled<<endl;

    if(filled>=(b/2.0)) {

        double base=a/2.0;
        int tt=1000;
        while((r-l)>=0.0000001) {
            double md=(r+l)/2.0;
           // cout<<md<<" ";

            if(f(md, base, b, filled)) {
                l=md;
            }
            else {
                r=md;
            }
        }

        cout<<(l+r)/2;

    }
    else {

        double area=x/a;
        double c=2*area/b;
        
        double ang=atan(b/c);
        cout<<ang*180/PI;

    }

   // cout<<f(80,base,b,filled)<<endl;

    

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char S[19];
int main(){
	int k;
	cin>>S + 1;
	k = strlen(S + 1);
	int cnt = 0;
	for (int i = 1;i <= k; i++){
		if(S[i] == 'o')cnt++;
	}
	if(cnt + 15 - k >= 8)puts("YES");
	else puts("NO");
	return 0;
}

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

int n, k, p1, x;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin >> n >> k;
    for(int i = 1, x; i <= n; i++){
        cin >> x;
        if(x == 1) p1 = i;
    }
    int ans = INT_MAX;
    for(int l = max(1, p1-k+1), i = 0; i < k && l <= p1; i++, l++){
        ans = min(ans, max(0,(l+k-3)/(k-1)) + max(0,(n-l-1)/(k-1)) + 1);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
function Main(input) {
  'use strict';

  const temp = input.split(" ");
  const n = parseInt(temp[0]);
  const startTaste = parseInt(temp[1]);
  const endTaste = startTaste + n - 1;
  const sum = (startTaste + endTaste) * n / 2;
  const product = startTaste * endTaste;
  if(product <= 0) console.log(sum)
  else if(startTaste > 0) console.log(sum - startTaste)
  else console.log(sum - endTaste)
  
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
using System;
using System.Linq;

namespace ABC064_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var num = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse).ToList();
            Console.WriteLine(num.Max() - num.Min());
        }
    }
}


Measured memory_bytes: 13268
#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"

def main():
    a,b,m = mi()
    alist = li()
    blist = li()
    ans = min(alist)+min(blist)
    for i in range(m):
        x,y,c = mi()
        ans = min(ans,alist[x-1]+blist[y-1]-c)
    print(ans)




main()



Measured memory_bytes: 20744
#include<iostream>
main(){for(;;){int d[5],s=0,i=0;for(;i<5;i++){int h;std::cin>>h;if(!h)return 0;s|=d[i]=1<<(h-1);}for(i=0;i<5;i++){int k=d[i];std::cout<<(s==7|s==k?3:((s^k)==k*2|(s^k)==k/4?1:2))<<"\n";}}}

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

int main(){
    int len[3];
    int n,A,B,C;

    cin >> n;

    for(int i = 0; i < n; ++i){
        cin >> len[0] >> len[1] >> len[2];
        sort(len, len + 3);
        A = len[0] * len[0];
        B = len[1] * len[1];
        C = len[2] * len[2];
        if(A + B == C){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
}


Measured memory_bytes: 3080
#include<cstdio>
#include<cstring>
const int N=3000+10;
char a[N],b[N];
int f[N][N],n,m,x[N][N],y[N][N];
char ch[N][N];
void pr(int n,int m)
{
	if(!(n&&m))return;
	pr(x[n][m],y[n][m]);
	if(ch[n][m]!=' ')printf("%c",ch[n][m]);
	return;
}
int main()
{
	scanf("%s%s",a+1,b+1);
	n=strlen(a+1);
	m=strlen(b+1);
	memset(ch,' ',sizeof(ch));
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			if(f[i][j-1]>f[i-1][j])
			{
				f[i][j]=f[i][j-1];
				x[i][j]=i;
				y[i][j]=j-1;
			}
			else
			{
				f[i][j]=f[i-1][j];
				x[i][j]=i-1;
				y[i][j]=j;
			}
			if(a[i]==b[j]&&f[i][j]<f[i-1][j-1]+1)
			{
				f[i][j]=f[i-1][j-1]+1;
				ch[i][j]=a[i];
				x[i][j]=i-1;
				y[i][j]=j-1;
			}
		}
	pr(n,m);
	return 0;
}


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

int main() {
  int N;
  scanf("%d", &N);
  int V[N], C[N];
  for (int i=0; i<N; i++) {
    scanf("%d", &V[i]);
  }
  for (int i=0; i<N; i++) {
    scanf("%d", &C[i]);
  }

  int ans = 0;
  for (int i=0; i<N; i++) {
    if (V[i] - C[i] > 0) {
      ans += (V[i] - C[i]);
    }
  }
  printf("%d\n", ans);
}


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

using namespace std;

//#define cin fi
//#define cout fo

//ifstream fi (".INP");
//ofstream fo (".INP");

int mark[100001];
vector<int > d[100001];

void dfs(int u, int n){
	mark[u] = 1;
	for (auto i : d[u]){
		if (mark[i] == 0 ){
			dfs(i, n);
		}
	}
}

int main(){
//	freopen("test.txt" , "r" , stdin);
//	ios_base:: sync_with_stdio(false);
//	cin.tie(0);
//	cout.tie(0);
	int n, m;
	cin >> n >> m ;

	for (int i = 1; i <= m ; i++){
		int x ,y;
		cin >> x >> y;
		d[x].push_back(y);
		d[y].push_back(x);
	}
	int cnt = 0;
	for (int i = 1; i <= n ; i++){
		if (mark[i] == 0) {
			cnt++;
			dfs(i, n);
		}
	}
	cout << cnt-1;
	
	return 0;
}




Measured memory_bytes: 10364
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

// 約数の列挙O(√n)
vector<ll> enum_divisors(ll n){
    vector<ll> res;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            res.push_back(i);
            // 重複しないならばiの相方であるN/iもpush
            if(i!=n/i) res.push_back(n/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}


int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> p=enum_divisors(m);
    ll ans=1;
    rep(i,p.size()){
        ll x=p[i]*(n-1);
        ll y=m-x;
        if(y<=0) continue;
        if(y%p[i]==0) ans=p[i];
    }

    cout<<ans<<endl;
}
    




Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    H,W=MI()
    grid=[ST() for _ in range(H)]
    
    ans = True
    stack = [(0,0)]
    visited = set()
    while(stack):
        v = stack.pop()
        visited.add(v)
        for dh,dw in [(-1,0), (1,0), (0,-1), (0,1)]:
            to_h,to_w = v[0]+dh, v[1]+dw
            if(not(0<=to_h<H) or not(0<=to_w<W)):
                continue
            if(to_h,to_w) in visited:
                continue
            if(grid[to_h][to_w] == "#" and -1 in (dh,dw)):
                ans = False
            if(grid[to_h][to_w] == "#"):
                stack.append((to_h,to_w))
        if(len(stack) >= 2): 
            ans = False   
    if(ans):
        print("Possible")
    else:
        print("Impossible")
if __name__ == '__main__':
    main()

Measured memory_bytes: 6232
#include <bits/stdc++.h>
 
using namespace std;
 
const long long INF=0x3f3f3f3f3f3f3f3fLL;
 
struct Set
{
    vector<pair<long long, long long>> s;
    vector<pair<long long, long long>> t;
    long long find_by_first(long long x)
    {
        auto it=lower_bound(s.begin(), s.end(), make_pair(x+1, -1LL));
        if(it==s.begin())
            return INF;
        return (--it)->second;
    }
    long long find_by_second(long long x)
    {
        auto it=lower_bound(t.begin(), t.end(), make_pair(x+1, -1LL));
        if(it==t.begin())
            return INF;
        return (--it)->second;
    }
    void init()
    {
        sort(s.begin(), s.end());
        for(int i=1; i<(int)s.size(); i++)
            s[i].second=min(s[i].second, s[i-1].second);
        sort(t.begin(), t.end());
        for(int i=1; i<(int)t.size(); i++)
            t[i].second=min(t[i].second, t[i-1].second);
    }
    void clear()
    {
        s.clear();
        t.clear();
    }
    void insert(long long x, long long y)
    {
        s.push_back({x, y});
        t.push_back({y, x});
    }
    size_t size()
    {
        return s.size();
    }
} s[131073];
 
int N;
long long X;
vector<int> adj[131073];
vector<int> d[131073];
int ok;
 
void dfs(int u)
{
    if(adj[u].empty())
    {
        s[u].clear();
        s[u].insert(0, 0);
        s[u].init();
        return;
    }
    int l=adj[u][0];
    int dl=d[u][0];
    int r=adj[u][1];
    int dr=d[u][1];
    s[u].clear();
    dfs(l);
    dfs(r);
    if(s[l].size()>s[r].size())
        swap(l, r), swap(dl, dr);
    long long L=X-dl-dr;
    for(auto& it: s[l].s)
    {
        long long v=s[r].find_by_first(L-it.second);
        if(v!=INF)
        {
            long long x=it.first+dl, y=v+dr;
            s[u].insert(x, y);
        }
        v=s[r].find_by_second(L-it.first);
        if(v!=INF)
        {
            long long x=v+dr, y=it.second+dl;
            s[u].insert(x, y);
        }
    }
    if(s[u].size()==0)
        ok=0;
    s[u].init();
}
 
int main()
{
    scanf("%d", &N);
    for(int i=2; i<=N; i++)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        adj[a].push_back(i);
        d[a].push_back(b);
    }
    long long lo=0, mid, hi=131072LL*N;
    while(lo<hi)
    {
        X=mid=(lo+hi)/2;
        ok=1;
        dfs(1);
        if(ok)
            hi=mid;
        else
            lo=mid+1;
    }
    printf("%lld\n", lo);
    return 0;
}

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

using namespace std;
typedef long long int ll;

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

	if (s == "Sunny")
	{
		cout << "Cloudy";
	}
	else if (s == "Cloudy")
	{
		cout << "Rainy";
	}
	else
	{
		cout << "Sunny";
	}

	return 0;
}


Measured memory_bytes: 256
N = int(input())

def main():

    P = [1 for i in range(N + 1)]

    for i in range(1, N + 1):
        if i * 2 > N:
            break
        for j in range(i * 2, N + 1, i):
            P[j] += 1
    res = 0

    for i in range(N + 1):
        res += i * P[i]

    print(res)

if __name__ == "__main__":
    main()

Measured memory_bytes: 219252
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
const int oo=1073741819;
using namespace std;
struct point{
	int x,y,A,B,D;
}G[2005];
int f[205][105][105],g[105][105][3],b[105][105],d[205][105][105];
int n,m,s,t,F;
inline void Up(int &x,int y)
{
	if (x>y) x=y;
}
int main()
{
	scanf("%d%d%d%d%d",&n,&m,&s,&t,&F);
	s++,t++;
	int id=0;
	for (int i=1;i<=m;i++) {
		scanf("%d%d%d%d%d",&G[i].x,&G[i].y,&G[i].A,&G[i].B,&G[i].D);
		G[i].x++,G[i].y++;
		if (G[i].A<G[i].B) id=i;
	}
	for (int P=1;P<=F;P++) {
		for (int i=1;i<=n;i++)
			for (int j=1;j<=n;j++) 
				if (i!=j) f[P][i][j]=d[P][i][j]=oo;else f[P][i][j]=d[P][i][j]=0;
		for (int i=1;i<=m;i++) {
			if (G[i].A<G[i].B) continue;
			int x=G[i].x,y=G[i].y;
			if (P>G[i].D) Up(f[P][x][y],G[i].A*G[i].D+G[i].B*(P-G[i].D));
			else Up(f[P][x][y],P*G[i].A);
		}
		for (int k=1;k<=n;k++)
			for (int i=1;i<=n;i++)
				if (f[P][i][k]<oo)
					for (int j=1;j<=n;j++)
						if (f[P][k][j]<oo)
							Up(f[P][i][j],f[P][i][k]+f[P][k][j]);
	}
	if (id)
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			for (int p=0;p<=F;p++) {
				int cos=0;
				if (p>G[id].D) cos=G[id].A*G[id].D+G[id].B*(p-G[id].D);
				else cos=G[id].A*p;
				if (f[F-p][i][j]<oo && f[p][i][G[id].x]<oo && f[p][G[id].y][j]<oo)
					Up(d[F][i][j],f[F-p][i][j]+f[p][i][G[id].x]+cos+f[p][G[id].y][j]);
			}
	int ans=min(f[F][s][t],d[F][s][t]);
	//cout<<f[F][s][s]<<endl;
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			if (f[F][s][i]<oo && d[F][i][j]<oo && f[F][j][t]<oo)
				Up(ans,f[F][s][i]+d[F][i][j]+f[F][j][t]);
	if (ans<oo) printf("%d\n",ans);
	else printf("Impossible\n");
	return 0;
}

Measured memory_bytes: 18828
// IOI 2021
#include <bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
 
////////////////////////////////////////////////////////////////////
 
const int N = 1e5 + 5;

int A[N];

int main() {
 
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));

	int n; cin >> n;
	ll ans = 0;
	for (int i = 0; i < n; i++) cin >> A[i];
	for (int i = 0; i < n;) {
		int j = i + 1; ll s = A[i];
		while (j < n && A[j]) s += A[j++];
		ans += s / 2;
		i = j;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4048
/******************************************
* AUTHOR : Lokesh goel*
* NICK : InsaneNerd *
* INSTITUTION : NIT Kurukshetra *
******************************************/
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 1000000000
#define N 100005
#define pii pair<int,int>
#define vp vector<pair<int,int > >
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define gsz(x) ((int)(x).size())
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cerr.tie(NULL);
#define endl "\n"
#define ms(x,v) memset(x,v,sizeof(x))

int main()
{
	fastio;
	string s;
	cin>>s;
	ll i,j,k,n=s.length();
	bool flag=true;
	for(i=0;i<n/2;i++)
	{
		if(s[i]!=s[n-i-1])
		{
			flag =false;
			break;
		}
	}
	if(flag)
	{
		for(i=0;i<n/4;i++)
		{
			if(s[i]!=s[n/2-i-1])
			{
				flag = false;
				break;
			}
		}

		for(i=n/2+1;i<3*n/4;i++)
		{
			if(s[i]!=s[n-i-1])
			{
				flag=false;
				break;
			}
		}
	}
	if(flag)
	{
		cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;


	return 0;
}

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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー

int main(int argc,char* argv[]){
    int n;
    cin >> n;

    vector<ll> a(n);
    for(auto &x:a)
        cin >> x;
    
    ll height=0;
    for(int i=1;i<a.size();i++){
        if(a[i-1]>a[i]){
            height+=a[i-1]-a[i];
            a[i]=a[i-1];
        }
    }

    cout << height << endl;

    return 0;
}


Measured memory_bytes: 4768