akhauriyash/Code-Regression huggingface dataset:
# 入力
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
BC = [list(map(int, input().split())) for _ in range(Q)]


array = [0]*(10**5+1)
total = sum(A)

for a in A:
    array[a] += 1

for bc in BC:
    b, c = bc
    total += c*array[b]-b*array[b]
    array[c] += array[b]
    array[b] = 0
    print(total)


Measured memory_bytes: 96568
import java.util.*;

public class Main {
   
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[][] td = new int[N][2];
    for (int i = 0; i < N; i++) {
      td[i][0] = sc.nextInt();
      td[i][1] = sc.nextInt();
    }
    Arrays.sort(td, (a,b)->b[1]-a[1]);
    
    boolean[] found = new boolean[N+1];
    PriorityQueue<Integer> pq1 = new PriorityQueue<>(Collections.reverseOrder());
    PriorityQueue<Integer> pq2 = new PriorityQueue<>(Collections.reverseOrder());
    for (int i = 0; i < N; i++) {
      int t = td[i][0];
      int d = td[i][1];
      if (found[t]) {
        pq2.offer(d);
      } else {
        pq1.offer(d);
        found[t] = true;
      }
    }
    
    long stack1Sum = 0;
    Stack<Integer> stack1 = new Stack<>();
    while (!pq1.isEmpty() && stack1.size() < K) {
      int d = pq1.poll();
      stack1.push(d);
      stack1Sum += d;
    }
    
    long rSum = 0;
    int r = 0;
    while (stack1.size()+r < K) {
      int q = pq2.poll();
      rSum += q;
      r++;
    }
    
    int x = stack1.size();
    long ans = stack1Sum+rSum+(long)x*x;
    while (stack1.size() > 0 && !pq2.isEmpty()) {
      int h = stack1.pop();
      stack1Sum -= h;
      rSum += pq2.poll();
      x = stack1.size();
      long tmp = stack1Sum+rSum+(long)x*x;
      ans = Math.max(ans, tmp);
    }

    System.out.println(ans);
  }
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  int n, m;
  cin >> n >> m;

  vvi g(n);
  vi ind(n);

  rep(i,0,m) {
    int u, v;
    cin >> u >> v;
    --u; --v;
    g[u].pb(v);
    ++ind[v];
  }

  queue<int> go;
  rep(i,0,n) if (not ind[i]) go.push(i);

  vi dp(n, 0);
  while (sz(go)) {
    int u = go.front(); go.pop();
    for (auto v: g[u]) {
      ckmax(dp[v], dp[u]+1);
      if (--ind[v] == 0) go.push(v);
    }
  }

  cout << *max_element(all(dp)) << '\n';
}

Measured memory_bytes: 6528
'use strict'

const INF = 900719925474099 // Number.MAX_SAFE_INTEGER / 10;

function Main(input){
	let temp = input.trim().split('\n');
	let n = parseInt(temp[0].split(' ')[0]);
	let k = parseInt(temp[0].split(' ')[1]);
	let h = temp[1].split(' ').map((v)=>parseInt(v));

	let step = new Array(n+10).fill(INF);
	step[0]=0;
	for(let i=0;i<n;i++){
		for(let j=1;j<=k;j++){
			step[i+j] = Math.min(step[i+j],step[i] + Math.abs(h[i]-h[i+j]));
		}
	}
	console.log(step[n-1]);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29140
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
const double PI  = 3.1415926535897932384626433832795028841971;
const long long int    INF = 100000000000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

long long n, s;
long long ans = INF;

int main(){
	cin >> n >> s;
	if(n < s){
		cout << -1 << endl;
		return 0;
	}
	if(n == s){
		cout << n+1 << endl;
		return 0;
	}
	for(ll i = 2;;i++){
		if(i*i > n) break;
		ll nn = n, cnt = 0;
		while(nn){
			cnt += (nn%i);
			nn /= i;
		}
		if(cnt == s){
			ans = i;
			break;
		}
	}
	for(ll i = 1;;i++){
		if(i*i > n-s) break;
		if((n-s)%i != 0) continue;
		ll p = (n-s)/i;
		ll q = (n-s)/p;
		if(p+1 > q && p+1 > s-q && s >= q) ans = min(ans,p+1);
		swap(p,q);
		if(p+1 > q && p+1 > s-q && s >= q) ans = min(ans,p+1);
	}
	if(ans == INF) ans = -1;
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import deque

n = ni()
a = list(li())

ans = deque([])
for i, ai in enumerate(a):
    if i%2 == 0:
        ans.append(ai)
    else:
        ans.appendleft(ai)
        
if n%2 == 1:
    print(*list(ans)[::-1])
else:
    print(*list(ans))

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

int main(){
	string S;
	cin >> S;
	
	int N = S.size();
	
	vector<int> ans(N);
	ans.assign(N,0);
	
	int count = 0;
	
	rep(i,N-1){
		if(S[i] == 'R'){
			count++;
		}
		if(S[i] == 'R' && S[i+1] == 'L'){
			ans[i+1] += count/2;
			ans[i] += (count+1)/2;
			count = 0;
		}
	}
	
	reverse(S.begin(),S.end());
	reverse(ans.begin(),ans.end());
	
	rep(i,N-1) {
		if (S[i] == 'L') {
			count++;
		}
		if (S[i] == 'L' && S[i + 1] == 'R') {
			ans[i + 1] += count / 2;
			ans[i] += (count + 1) / 2;
			count = 0;
		}
	}
	
	reverse(ans.begin(),ans.end());
	rep(i,N){
		cout << ans[i] << " ";
	}
    return 0;
}



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

int main() {

	int N,out;
	cin >> N;
	
	out = 0;
	
	for(int i = 0;i < N; i++){
		int l,r;
		cin >> l >> r;
		
		out += r-l +1;
    }

    cout << out;
    
}


Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#define eps 1e-8
#define zero(x) (((x)>0?(x):-(x))<eps)

#define pause cout << " press ansy key to continue...",  cin >> chh
#define file_r(x) freopen(x,  "r",  stdin)
#define file_w(x) freopen(x,  "w",  stdout)
#define lowbit(x) ((x) & (-x))
#define repit(i, c) for (__typeof__((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repe(i, u) for (int i = head[u]; i != -1; i = nxt[i])
#define repd(i, n) for (int i = (n - 1); i >= 0; i--)
#define FOR(i, n, m) for (int i = (n); i <= (m); i++)
#define FORD(i, n, m) for (int i = (n); i >= (m); i--)
#define pb push_back
#define X first
#define Y second
#define ins insert
#define rb rbegin
#define be begin
#define er erase
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define SZ(c) (c).size()
#define ALL(c) (c).begin(), (c).end()
#define sqr(r) ((LL) (r) * (r))
#define dis(x1, y1, x2, y2) (((x1) - (x2)) * ((x1) - (x2)) + ((y1) - (y2)) * ((y1) - (y2)))
#define FASTIO ios::sync_with_stdio(false);cin.tie(0)

#define sc(x) cout << #x" = " << x << endl, system("pause")
#define sc2(x, y) cout << #x" = " << x << " " << #y" = " << y << endl, system("pause")
#define sc3(x, y, z) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << endl, system("pause")
#define sc4(x, y, z, w) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << " " << #w" = " << w << endl, system("pause")

#define in(n) scanf("%d", &n)
#define in2(n, m) scanf("%d %d", &n, &m)
#define in3(x, y, z) scanf("%d %d %d", &x, &y, &z)

using namespace std;
int chh;

typedef vector<int> vi;
typedef set<int> si;
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<int, pii> pi3;
typedef vector< pair<int, int> > vpii;
typedef long long LL;

int A, B, C;

int main() {
	while (~in3(A, B, C)) {
		if (B >= C) printf("%d\n", B + C);
		else printf("%d\n", B * 2 + min(A + 1, C - B));
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

void solve() {
    int n; cin >> n;
    int l[20]; 
    int lmax = 0, lsum = 0;
    rep(i, n) {
        cin >> l[i];
        lsum += l[i];
        lmax = max(lmax, l[i]);
    }
    if(lmax < lsum - lmax) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int maxn = 1e6 + 7;
const int mod = 1e9 + 7;

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if((a == b&&b !=c)||(a == c&&b !=c)||(c == b&&a !=c) ){
		printf("Yes\n");
	}else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define max(a,b) ((a)>(b)?(a):(b))
int main(){
  long int n,m,i,ans=1;
  scanf("%ld%ld",&n,&m);
  long int cd[100001],cent=sqrtl(m),j=0;
  for(i=1;i<cent;i++){
    if(m%i==0){
      cd[j]=i;
      cd[j+1]=m/i;
      j+=2;
    }
  }
  if(m%cent==0){
    cd[j]=cent;
    j++;
  }
  else cd[j]=0;
  for(i=0;i<=j;i++) if(cd[i]<=m/n)ans=max(ans,cd[i]);
  printf("%ld",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C;
  cin>>A>>B>>C;
  int G=A+B-C;
  int F=A+G-C;
  int I=B+C-G;
  int go=A+C+I;
  int D=go-A-B;
  int E=go-A-G;
  int H=go-G-I;
  cout<<A<<" "<<B<<" "<<D<<endl;
  cout<<E<<" "<<C<<" "<<F<<endl;
  cout<<G<<" "<<H<<" "<<I<<endl;
}

Measured memory_bytes: 3516
#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() {
  int N;
  cin >> N;
  vector<int> pos(N + 1);
  rep(i, N) {
    int p;
    cin >> p;
    pos.at(p) = i + 1;
  }

  multiset<int> ms;
  rep(i, 2) {
    ms.insert(0);
    ms.insert(N + 1);
  }
  ll ans = 0;
  for (int i = N; i >= 1; i--) {
    // インデックスの順は l1 < l2 < pos.at(i) < r1 < r2 となるようにする
    ms.insert(pos.at(i));
    auto itr = ms.find(pos.at(i));
    ll l1 = *prev(itr, 2);
    ll l2 = *prev(itr, 1);
    ll r1 = *next(itr, 1);
    ll r2 = *next(itr, 2);

    ans += ((l2 - l1) * (r1 - pos.at(i)) + (pos.at(i) - l2) * (r2 - r1)) * i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5376
#include<iostream>
#include<math.h>
using namespace std;
typedef long long int ll;
int main()
{
    string s,t;
    cin>>s>>t;
    ll mini=10000000001,cnt=0;
    for(ll i=0;i<=s.length()-t.length();i++)
    {
        cnt=0;
        for(ll j=0;j<t.length();j++)
        {
            if(s[i+j]!=t[j])
            cnt++;
        }
        mini=min(mini,cnt);
    }
    cout<<mini;
}


Measured memory_bytes: 3132
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true;
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        dfs(G, next_v); // 再帰的に探索
    }
}

void Main()
{
    // 頂点数と辺数
    int N, M; 
    cin >> N >> M;

    // グラフ
    //Graph G(N);
  	vector<pair<int,int>> E(M);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
      	a--, b--;
        //G[a].push_back(b);
        // 無向グラフの場合は以下を追加
        //G[b].push_back(a);
      	E[i].first = a;
      	E[i].second = b;
    }
	
	int ans = 0;
  	rep(i,M){
      	Graph H(N);
      	rep(j,M){
          	if(j!=i){
      			H[E[j].first].push_back(E[j].second);
      			H[E[j].second].push_back(E[j].first);
            }
        }
        // 全頂点が訪問済みになるまで探索
    	int count = 0;
    	seen.assign(N, false);
    	for (int v = 0; v < N; ++v) {
        	if (seen[v]) continue; // v が探索済みだったらスルー
        	dfs(H, v); // v が未探索なら v を始点とした DFS を行う
        	++count;
    	}
    	if(count>1){ans++;}
    }
  	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
vl modinv;
void fillModInv(ll n, ll mod){
  modinv = vl(n+1);
  modinv[1] = 1;
  FOR(i,2,n+1){
    modinv[i] = modinv[mod%i] * (mod - mod/i) % mod;
  }
}
/*}}}*/
int main() {
  ll n,a,b;
  cin >> n >> a >> b;

  ll s = a+b;
  ll ans = (n / s) * a;

  ans += min(n%s,a);
  
  //cout << fixed << setprecision(10);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
def run():
  N, K = map(int, input().split())
  C = [0] * N
  counter = 0
  for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    
    for j in range(d):
      C[A[j]-1] += 1
  
  for i in range(N):
    if C[i]==0:
      counter+=1
    else:
      pass
  print(counter)

if __name__ == "__main__":
  run()

Measured memory_bytes: 9152
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcountll(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};
//vector<int> bucket[MAX_N/1000];

int main(void){
    int N;
    cin >> N;
    int A[N],B[N];
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];
    int dp[(1<<N)][51];
    rep(i,(1<<N)) rep(j,51) dp[i][j]=INF;
    dp[0][0]=0;
    rep(i,(1<<N)){
        int use=Flagcount(i);
        int p=use;
        vector<pint> rem;
        rep(j,N) if(!(i&(1<<j))) rem.push_back(pint(j,p++));
        rep(j,51){
            if(dp[i][j]>=INF) continue;
            for(int k=0;k<rem.size();k++){
                int num=abs(rem[k].first-use)%2?B[rem[k].first]:A[rem[k].first];
                if(num>=j){
                    dp[i|(1<<rem[k].first)][num]=min(dp[i|(1<<rem[k].first)][num],dp[i][j]+abs(rem[k].second-rem[k].first));
                }
            }
        }
    }
    int ans=INF;
    rep(i,51) ans=min(ans,dp[(1<<N)-1][i]);
    if(ans==INF) cout << -1 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 55832
import sys
from operator import itemgetter, attrgetter
from itertools import starmap
import cmath
from math import isinf, sqrt, acos, atan2
readline = sys.stdin.readline
EPS = 1e-9
ONLINE_FRONT = -2
CLOCKWISE = -1
ON_SEGMENT = 0
COUNTER_CLOCKWISE = 1
ONLINE_BACK = 2
class Circle(object):
    __slots__ = ('c', 'r')
    def __init__(self, c, r):
        self.c = c
        self.r = r
class Segment(object):
    __slots__ = ('fi', 'se')
    def __init__(self, fi, se):
        self.fi = fi
        self.se = se
Line = Segment
def cross(a, b):
    return a.real * b.imag - a.imag * b.real
def dot(a, b):
    return a.real * b.real + a.imag * b.imag
def norm(base):
    return abs(base) ** 2
def project(s, p2):
    base = s.fi - s.se
    r = dot(p2 - s.fi, base) / norm(base)
    return s.fi + base * r
def reflect(s, p):
    return p + (project(s, p) - p) * 2.0
def ccw(p1, p2, p3):
    a = p2 - p1
    b = p3 - p1
    if cross(a, b) > EPS: return 1
    if cross(a, b) < -EPS: return -1
    if dot(a, b) < -EPS: return 2
    if norm(a) < norm(b): return -2
    return 0
def intersect4(p1, p2, p3, p4):
    return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 and
			ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0)
def intersect2(s1, s2):
    return intersect4(s1.fi, s1.se, s2.fi, s2.se)
def getDistance(a, b):  return abs(a - b)
def getDistanceLP(l, p):
    return abs(cross(l.se - l.fi, p - l.fi) / abs(l.se - l.fi))
def getDistanceSP(s, p):
    if dot(s.se - s.fi, p - s.fi) < 0.0: return abs(p - s.fi)
    if dot(s.fi - s.se, p - s.se) < 0.0: return abs(p - s.se)
    return getDistanceLP(s, p)
def getDistances(s1, s2):
    if intersect2(s1, s2): return 0.0
    return min(getDistanceSP(s1, s2.fi), getDistanceSP(s1, s2.se),
               getDistanceSP(s2, s1.fi), getDistanceSP(s2, s1.se))
def getCrossPoint(s1, s2):
	base = s2.se - s2.fi
	d1 = abs(cross(base, s1.fi - s2.fi))
	d2 = abs(cross(base, s1.se - s2.fi))
	t = d1 / (d1 + d2)
	return s1.fi + (s1.se - s1.fi) * t
def getCrossPointsCL(c, l):
    pr = project(l, c.c)
    e = (l.se - l.fi) / abs(l.se - l.fi)
    base = sqrt(c.r * c.r - norm(pr - c.c))
    return Segment(*sorted((pr + e * base, pr - e * base)), key=attrgetter('real', 'imag'))
def getCrossPointsCC(c1, c2):
    d = abs(c1.c - c2.c)
    a = acos((c1.r * c1.r + d * d - c2.r * c2.r) / (2.0 * c1.r * d))
    t = cmath.phase(c2.c - c1.c)
    return Segment(*sorted((c1.c + cmath.rect(c1.r, t + a), c1.c + cmath.rect(c1.r, t - a)), key=attrgetter('real', 'imag')))
x, y, r = map(int, readline().split())
c1 = Circle(complex(x, y), r)
x, y, r = map(int, readline().split())
c2 = Circle(complex(x, y), r)
cpc = getCrossPointsCC(c1, c2)
print(*map('{:.10f}'.format, (cpc.fi.real, cpc.fi.imag, cpc.se.real, cpc.se.imag)))

Measured memory_bytes: 8396
#include <bits/stdc++.h>
using namespace std;
int main(){
    int h, n;
    cin >> h >> n;
    int a[200000];
    int sumA = 0;
    for(int i=0; i<n; i++){
        cin >> a[i];
        sumA += a[i];
    }
    if(h <= sumA){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define len(x) ((int)(x).size())
#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);

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

const ll LINF = 1e18;
const int INF = 1e9;
const int MOD = 1e9+7;

/// command for char arrays with spaces -> scanf(" %[^\n]", text);
 
////////////////////////// Solution starts below. //////////////////////////////

int main(){

	fastio;
    int n, base, ans = 0;
    cin >> n >> base;
    while(n > 0){
    	ans++;
    	n /= base;
    }
	cout << ans << endl;
	return 0;
}

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

int main() {
    int a, b, c, i = 0, j = 0;
    double d, r, f;
    cin >> a >> b ;
    d = 1.0*a / b;
    printf("%d %d %.8lf", a / b, a % b, d);
    return 0;
}



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

int main() {
	int w,a,b;
	scanf("%d %d %d",&w,&a,&b);
	if (b<=a) {
		if (b+w>=a) {
			printf("%d\n",0);
		}
		else printf("%d\n",a-(b+w));
	}
	else {
		if (b<=a+w) {
			printf("%d\n",0);
		}
		else printf("%d\n",b-(a+w));
	}
	return 0;
}

Measured memory_bytes: 256
'use strict'
function Main(input){
  input=input.split(/\n/);
  var N=input.shift()-0;
  var S=input.join('').trim().replace(/\s+/,'').split('');
  var B=0,W=0;
  for(let i=0;i<N;i++){
    if(S[i]==='.'){
      W++;
    }else{
      B++;
    }
  }
  var a=[W];
  for(let i=0;i<N;i++){
    let d=(S[i]==='.'?-1:1);
    a.push(a[i]+d);
  }
  var ans=a.reduce((A,c)=>Math.min(A,c));
  console.log(ans);
}



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


Measured memory_bytes: 21836
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1e9+7
#define PI acos(-1.0)
#define ll long long
#define INF 1000000001

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  char r;
  string g;
  cin>>r>>g[0]>>g[1];
  int c=stoi(g);
  if(c%4==0){
    P("YES");
  }else{
    P("NO");
  }
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define clr(s, x) memset(s, x, sizeof(s))
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
inline int read(){int r=0;char c=getchar();while(c<'0'||c>'9') {c=getchar();}while(c>='0'&&c<='9') {r=r*10+c-'0';c=getchar();}return r;}
inline ll readll(){ll r=0;char c=getchar();while(c<'0'||c>'9') {c=getchar();}while(c>='0'&&c<='9') {r=r*10+c-'0';c=getchar();}return r;}
inline ll qpow(ll a,ll b,ll mod){ll res=1;while(b){if(b&1)res = (res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}
inline ll gcd(ll a,ll b){while(b^=a^=b^=a%=b);return a;}
const double eps = 1e-8;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int MAXN = 1e6;
const int MAXM = 1e5;
typedef long long ll;
ll dp[MAXN][3];
ll a[MAXN][3];
int main(){
	ll n;
	cin>>n;
	for(ll i=1;i<=n;i++){
		for(ll j=0;j<3;j++){
			cin>>a[i][j];
		}
	}
	memset(dp,0,sizeof(dp));
	for(ll j=0;j<3;j++) dp[1][j]=a[1][j];
	for(ll i=2;i<=n;i++){
		dp[i][0]=max(dp[i-1][1]+a[i][0],dp[i-1][2]+a[i][0]);
		dp[i][1]=max(dp[i-1][0]+a[i][1],dp[i-1][2]+a[i][1]);
		dp[i][2]=max(dp[i-1][0]+a[i][2],dp[i-1][1]+a[i][2]);
	}
	cout<<max(max(dp[n][1],dp[n][0]),dp[n][2])<<endl;
	return 0;
}


Measured memory_bytes: 28672
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

map<list<char>, int> m;

int dfs(list<char> ls){
    if(m.count(ls)) m[ls];

    set<int> ret;
    auto end = --ls.end();
    for(auto it = ++ls.begin(); it != end; it++){
        if(*prev(it, 1) != *it && *prev(it, 1) != *next(it, 1) && *it != *next(it, 1)){
            //for(auto i:ls){ cout << i << ' '; } cout << endl;
            char foo = *it;
            it = ls.erase(it);
            ret.emplace(dfs(ls));
            ls.insert(it, foo);
            //it++;
            --it;
        }
    }

    rep(i,1e8) if(not ret.count(i)) return m[ls] = i;
    return 1e8;
}

int main(){
    string s;
    cin >> s;
    bool f = (s.front() != s.back()) xor (s.size() % 2 == 0);
    cout << (f ? "First" : "Second") << endl;
}


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

#define endl '\n'
#define db(x) cerr << #x << " == " << x << endl
#define dbs(x) cerr << x << endl
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3f

typedef long long ll;
typedef pair <int, int> pii;
typedef vector<int> vi;
const int N = 1<<16+5;
ll a[20][20], sum[N], dp[N];
int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for(int i=0; i<n; i++)
    for(int j=0; j<n; j++)
      cin >> a[i][j];

  dp[0]=0;
  for(int p=1; p<(1<<n); p++){
    for(int i=0; i<n; i++){
      if(!(p&(1<<i))) continue;
      for(int j=i+1; j<n; j++){
        if(!(p&(1<<j))) continue;
        sum[p]+=a[i][j];
      }
    }
    dp[p]=-linf;
  }

  for(int p=0; p<(1<<n); p++){
    vector <ll> cur;
    for(int  i=0; i<n; i++) if(p&(1<<i)) cur.pb(i);
    for(int k=0; k<(1<<cur.size()); k++){
      int sp=0;
      for(int i=0; i<n; i++) if(k&(1<<i)) sp^=(1<<cur[i]);
      dp[p]=max(dp[p], sum[sp]+dp[p-sp]);
    }
  }
  cout << dp[(1<<n)-1] << endl;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "trace.h"
#else
#define trace(args...)
#endif

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
void solve(int test) {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    int cnt = 0;
    while (b <= a) b *= 2, cnt++;
    while (c <= b) c *= 2, cnt++;
    if (cnt <= k) cout << "Yes";
    if (cnt > k) cout << "No";
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; i++) {
        // cout << "Case #" << i << ": ";
        solve(i);
        cout << "\n";
    }
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
const long long MOD=1e9+7;
int main(){
  long long n,x,ans=0;
  cin>>n>>x;
  long long a,b;
  cin>>a;
  if(a>x){
    ans+=a-x;
    a=x;
  }
  for(int i=1;i<n;++i){
    cin>>b;
    ans+=max(0LL,a+b-x);
    b-=max(0LL,a+b-x);
    a=b;
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int n, m;
    cin >> n >> m;

    vector<vector<int>> graph(n);
    
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    vector<int> in(n, -1);
    vector<int> up(n, n + 123);
    int idx = 0;
    int res = 0;
    function<void(int,int)> dfs = [&](int u, int p) {
        in[u] = ++idx;
        up[u] = in[u];
        for (auto v : graph[u]) {
            if (v == p) {
                continue;
            }

            if (in[v] >= 0) {
                up[u] = min(up[u], in[v]);
            } else {
                dfs(v, u);
                up[u] = min(up[u], up[v]);
                if (up[v] > in[u]) {
                    ++res;
                }
            }
        }
    };

    dfs(0, -1);

    cout << res << '\n';



    return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
int n,k,d,x;
map<int,int> v;
int main()
{
	cin>>n>>k;
	while(k--)
	{
		cin>>d;
		while(d--)
		{
			cin>>x;
			v[x]++;
		}
	}
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		if(!v[i]) sum++;
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m,c=0,a=0,i,p[100000];
    string s[100000]; 
    cin >> n >> m;
    bool mondai[1000000], f[1000000];
    for(i=0;i<m;i++)
    {
        cin >> p[i] >> s[i];
    }
    for(i=0;i<n;i++)
    {
        mondai[i]=false;
        f[i]=false;
    }
    for(i=0;i<m;i++)
    {
        if(s[i]=="AC")
        {
            f[p[i]]=true;
        }
    }
    for(i=0;i<m;i++)
    {
        if(mondai[p[i]]==false && f[p[i]]==true)
        {
            if(s[i]=="WA")
            {
                c++;
            }
            else if(s[i]=="AC")
            {
                a++;
                mondai[p[i]]=true;
            }
        }
    }
    cout << a << " " << c << endl;
 
}


Measured memory_bytes: 7312
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		char[] ch = scn.nextLine().toCharArray();
		int k = ch.length;
		int ans = 0;
		for(int i = 0;i < k;i++) {
			if(ch[i] == 'o') {
				ans++;
			}
		}
		System.out.println((15-k + ans>=8)?"YES":"NO");
		}

}


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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec g(nmax);





void solve4ts()
{
    
    int h,w;cin>>h>>w;
    vector<string> s(h);
    rep(i,h) cin>>s[i];
    vvec dp(110,vec(110,INF));
    dp[0][0]=0;
    if(s[0][0]=='#') dp[0][0]++;

    rep(i,h){
        rep(j,w){
            int nx=i+1;
            int ny=j;
            if(nx<h){
            if(s[nx][ny]=='#'&&s[i][j]=='.') chmin(dp[nx][ny],dp[i][j]+1);
            else chmin(dp[nx][ny],dp[i][j]);
            }
            nx=i;
            ny=j+1;
            if(ny<w){
            if(s[nx][ny]=='#'&&s[i][j]=='.') chmin(dp[nx][ny],dp[i][j]+1);
            else chmin(dp[nx][ny],dp[i][j]);
            }
        }
    }    
    cout<<dp[h-1][w-1]<<endl;
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

Measured memory_bytes: 5120
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main(void) {
    
    string s,t;
    cin>>s>>t;
    int a,b;
    cin>>a>>b;
    string u;
    cin>>u;
    if(s==u)cout<<a-1<<" "<<b<<endl;
    else cout<<a<<" "<<b-1<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

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

    if (s[0] != 'A') {
        cout << "WA" << endl;
        return 0;
    }

    int cindex = 0, cnum = 0;
    for (int i = 2; i < s.size() - 1; i++) {
        if (s[i] == 'C') {
            cindex = i;
            cnum++;
        }
    }

    if (cnum != 1) {
        cout << "WA" << endl;
        return 0;
    }

    for (int i = 1; i < s.size(); i++) {
        if (i == cindex) {
            continue;
        }

        if (s[i] < 'a') {
            cout << "WA" << endl;
            return 0;
        }
    }

    cout << "AC" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
using namespace std;
int i,j,k,n,m;
string s;

int main() {
  long long x,y; cin >> x>> y;
  long long div = y/x;
  long long exp=0;
  while ((long long)pow(2,exp) <=div) {
    ++exp;
  }
  cout << exp;
  return 0;
}

Measured memory_bytes: 384
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

int h,w;
vector<string> vv;
vvint vis;

bool inside(int a, int b){
	return 0<=a&&a<h&&0<=b&&b<w;
}

bool dfs(int y, int x){
	vis[y][x]=1;
	if(y==h-1&&x==w-1) return true;
	if(x==w-1){
		if(vv[y+1][x]=='#'){
			return dfs(y+1, x);
		}
		else{
			return false;
		}
	}
	else if(y==h-1){
		if(vv[y][x+1]=='#'){
			return dfs(y, x+1);
		}
		else{
			return false;
		}
	}
	else{
		if(vv[y+1][x]=='#'&&vv[y][x+1]=='#'){
			return false;
		}
		else if(vv[y+1][x]=='#'){
			return dfs(y+1,x);
		}
		else if(vv[y][x+1]=='#'){
			return dfs(y, x+1);
		}
		else{
			return false;
		}
	}
	return false;
}


void mainmain(){
	cin>>h>>w;
	initvv(vis,h,w,0);
	vv=vector<string>(h);
	rep(i,h) cin>>vv[i];
	bool ok = dfs(0,0);
	rep(i,h){
		rep(j,w){
			if(vis[i][j]==0&&vv[i][j]=='#') ok=false;
		}
	}
	if(ok){
		cout<<"Possible"<<endl;
	}
	else{
		cout<<"Impossible"<<endl;
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>

using namespace std;
int m,a,b,n,res;
int main(){
	ios_base::sync_with_stdio(0);
	cin>>n>>a>>b;
	if(a<b)
	swap(a,b);
	cout<<(((a-b)%2)?"Borys":"Alice")<<std::endl;
    return 0;
}


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

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  
  if (C - (A - B) < 0){
    cout << 0 << endl;
  }
  else{
    cout << C - (A - B) << endl;
  }
}

Measured memory_bytes: 3628
s = list(input())
ans = 0
for i in range(1<<len(s)-1):
    nums = []
    cnt = 0
    for j in range(len(s)):
        if (i>>j) & 1 == 1:
            nums.append(s[cnt:j+1])#j番目の要素までのスライス
            cnt = j+1
    nums.append(s[cnt:len(s)+1])#上のループではLen(s)-1 番目の要素まで、Len(s)番目はここで
    for k in range(len(nums)):
        ans += int("".join(nums[k]))
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n;
char s[100000];
int a[100000],ans=1;

void A(int &x,int t){
  if(x==t||x==0)x=t;
  else ans=0;
}
bool check(){
  ans=1;
 for(int i=1;i<n;i++){
    if(a[i]==1){
      if(s[i]=='o'){
	if(a[i-1]==1)A(a[(i+1)%n],1);//1 1 
	else A(a[(i+1)%n],-1);               //0 1 
      }
      else{
	if(a[i-1]==1)A(a[(i+1)%n],-1);
	else A(a[(i+1)%n],1);
      }
    }
    else{
      if(s[i]=='o'){
	if(a[i-1]==1)A(a[(i+1)%n],-1);//1 0
	else A(a[(i+1)%n],1);               //0 0
      }
      else{
	if(a[i-1]==1)A(a[(i+1)%n],1);
	else A(a[(i+1)%n],-1);
      }
    }
 }
 return ans;
}
int main(){
  cin>>n;
  int aans=0;
  for(int i=0;i<n;i++)
    cin>>s[i];
  if(s[0]=='o'){
    memset(a,0,sizeof(a));
    a[n-1]=1,a[0]=1,a[1]=1;
    if(check())aans=1;
    if(!aans){
      memset(a,0,sizeof(a));
      a[n-1]=-1,a[0]=1,a[1]=-1;
      if(check())aans=1;
    }
    if(!aans){
      memset(a,0,sizeof(a));
      a[n-1]=-1,a[0]=-1,a[1]=1;
      if(!aans&&check())aans=1;
    }
    if(!aans){
      memset(a,0,sizeof(a));
      a[n-1]=1,a[0]=-1,a[1]=-1;
      if(!aans&&check())aans=1;
    }
  }
  else{
    memset(a,0,sizeof(a));
    a[n-1]=-1,a[0]=1,a[1]=1;
    if(!aans&&check())aans=1;
    if(!aans){
      memset(a,0,sizeof(a));
      a[n-1]=1,a[0]=1,a[1]=-1;
      if(!aans&&check())aans=1;
    }
    if(!aans){
      memset(a,0,sizeof(a));
      a[n-1]=-1,a[0]=1,a[1]=1;
      if(!aans&&check())aans=1;
    }
    if(!aans){
      memset(a,0,sizeof(a));
      a[n-1]=-1,a[0]=-1,a[1]=-1;
      if(!aans&&check())aans=1;
    }
  }
  
  if(aans)
    for(int i=0;i<n;i++){
      if(a[i]==1)cout<<"S";
      else cout<<"W";
    }
  else cout<<-1;
  cout<<endl;
  return 0;
}


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

int main(){
	
	int massnum, count2, count3, judge, judge2;
	
	count2 = 0;
	count3 = 0;
	judge = 0;
	judge2 = 0;
	
	cin >> massnum;
	
	vector<int> numbers(massnum);
	
	for(int count1 = 0; count1 < massnum; count1 ++){
		cin >> numbers.at(count1);
	}
	
	while(count2 < massnum){
	
		judge = (count2 + 1) % 2;

		judge2 = numbers.at(count2) % 2;
		
		if(judge != 0 && judge2 != 0){ 
			count3 ++;
		}
		
		count2 ++;                    
	}
	
	cout << count3 << endl; 
	
	
} 

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

const int inf = 1e9;
const ll linf = 1e18;

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

    ll x, y; cin >> x >> y;
    cout << __lg(y / x) + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n, m, a, h, i, ans=0, max=0, t, shot = 0;
    cin >> n >> m;
    for (i = 0; i < m; i++) {
        cin >> a >> h;
        if (n > (a + h)) {
            shot++;
        } else {
            if(a < n) {
                ans += t = n - a;
                if (t > max) {
                    max = t;
                }
            }
        }
    }
    if (shot == 1) {
        cout << ans << endl;

    } else {
        cout << ans - max << endl;
    }
    return 0;
}



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

//ball,boxはどちらも区別できる。またballの入れ方に制限はない。
//なおballは必ずどこかのboxに属するものとする。
//(属さない場合があるときは、属さないballのためのboxを作る。つまりbox += 1)
long long Mapping1(long long ball,long long box){
    long long MOD = 1000000007;
    long long A = 1;
    for(long long i = 0; i < ball;++i){
        A *= box;
        A %= MOD;
    }
    return A;
}


signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    ll n,k;cin >> n >> k;
    ll ans = Mapping1(n,k);
    cout << ans << endl;
}


Measured memory_bytes: 3208
import itertools
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
l=list(itertools.product([-1,0,1],repeat=2))

for i in range(h):
    for j in range(w):
        if s[i][j]=='.':
            cnt = 0
            for k in l:
                x = i+k[0]
                y = j+k[1]
                if 0<=x<=h-1 and 0<=y<=w-1:
                    if s[x][y]=='#':
                        cnt+=1
            s[i][j]=str(cnt)
for i in s:
    print(''.join(i))

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

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

    int ans = 0;
    rep(i, s.size()) {
        if(s[i] == t[i]) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define Mp make_pair
#define pb push_back

using ll = long long;
using db = double;
using pii = pair<int, int>;
using vi = vector<int>;
mt19937 mrand(time(0));
ll get(ll r) { return ((ll)mrand() * mrand() % r + r) % r; }
ll get(ll l, ll r) { return get(r - l + 1) + l; }

const int P = 1e9 + 7;
ll n, a[200100];
signed main() {
    scanf("%lld", &n); ll sum = 0;
    for(int i = 1; i <= n; i++) scanf("%lld", &a[i]), (sum += a[i]) %= P;
    sum = sum * sum % P;
    for(int i = 1; i <= n; i++) (sum += P - a[i] * a[i] % P) %= P;
    printf("%lld\n", (sum * ((P + 1) / 2)) % P);
    fprintf(stderr, "time=%.4f\n", (db)clock()/CLOCKS_PER_SEC);
    return 0;
    /* 取模直接除，爆零两行泪
     * 不开ll见祖宗
     */
}

Measured memory_bytes: 5392
n = list(str(input()))
n.append(0)
c = 0
t = [0]

for i in range(len(n)-1):
        if n[i] == "A" or n[i] == "T" or n[i] == "G" or n[i] == "C":
                c += 1
                if n[i+1] == "A" or n[i+1] == "T" or n[i+1] == "G" or n[i+1] == "C":
                        continue
                else:
                        t.append(c)
                        c = 0

print(max(t))

Measured memory_bytes: 3064
import java.io.FileNotFoundException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {
		new Main().run();
	}

	void run() throws FileNotFoundException {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		char[][] a = new char[H][W];
		ArrayList<Integer>[] g = new ArrayList[H + W];
		for (int i = 0; i < H; ++i) {
			a[i] = sc.next().toCharArray();
		}
		int o = Math.max(H, W);
		MF mf = new MF(2 * o + 3);
		// 2*H*W+1:s
		// 2*H*W+2:t
		int s = 2 * o + 1;
		int t = 2 * o + 2;
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				if (a[i][j] == 'S') {
					mf.ae(s, i, 999999);
					mf.ae(s, o + j, 999999);
				} else if (a[i][j] == 'T') {
					mf.ae(i, t, 999999);
					mf.ae(o + j, t, 999999);
				} else if (a[i][j] == 'o') {
					mf.ae(i, o + j, 1);
					mf.ae(o + j, i, 1);
				}
			}
		}
		int tot = mf.solve(s, t);
		if (tot >= 999999) {
			System.out.println(-1);
		} else {
			System.out.println(tot);
		}
	}

	class MF {
		int n;
		int[][] cap;
		int[][] flow;
		ArrayList<Integer>[] g;

		public MF(int n) {
			this.n = n;
			cap = new int[n][n];
			flow = new int[n][n];
			g = new ArrayList[n];
			for (int i = 0; i < n; ++i) {
				g[i] = new ArrayList<>();
			}
		}

		void ae(int a, int b, int w) {
			cap[a][b] = w;
			g[a].add(b);
		}

		int solve(int s, int t) {
			int tot = 0;
			while (true) {
				int[] pre = new int[n];
				Arrays.fill(pre, -1);
				ArrayDeque<Integer> que = new ArrayDeque<>();
				que.add(s);
				out: while (!que.isEmpty()) {
					int v = que.poll();
					for (int i = 0; i < n; ++i) {
						if (cap[v][i] - flow[v][i] > 0 && pre[i] == -1 && i != s) {
							pre[i] = v;
							que.add(i);
							if (i == t) {
								break out;
							}
						}
					}
				}
				if (pre[t] == -1)
					break;
				int inc = Integer.MAX_VALUE / 16;
				for (int i = t; pre[i] != -1; i = pre[i]) {
					inc = Math.min(inc, cap[pre[i]][i] - flow[pre[i]][i]);
				}
				for (int i = t; pre[i] != -1; i = pre[i]) {
					flow[pre[i]][i] += inc;
					flow[i][pre[i]] -= inc;
				}
				tot += inc;
			}
			return tot;
		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 25340