akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
順列かな
いや
3333
順列でいくか
だいたい30個･･･
*/
int main(){
  ll N,ans=0; cin>>N;
  vector<ll> A(0,0);
  for(ll i=1; i<=7; i++){//3の数
    for(ll j=1; j<=8-i; j++){//5の数
      for(ll k=1; k<=9-i-j; k++){//7の数
        A.assign(0,0);
        for(ll ii=0; ii<i; ii++) A.emplace_back(3);
        for(ll jj=0; jj<j; jj++) A.emplace_back(5);
        for(ll kk=0; kk<k; kk++) A.emplace_back(7);
        ll cnt=i+j+k;
        do{
          ll m=0;
          for(ll n=0; n<cnt; n++) m=m*10+A[n];
          if(m<=N) ans++;
        }while(next_permutation(A.begin(), A.end()));
      }
    }
  }
  cout<<ans<<endl;
}

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

int main() {

	int X, Y;
	cin >> X >> Y;

	for (int turu = 0; turu < X + 1; turu++) {
		int kame = X - turu;
		if (2 * turu + 4 * kame == Y) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3640
N,K=map(int,input().split())
import numpy as np
H=np.array([10**9]*(K-1)+list(map(int,input().split())))
dp=np.zeros(N+K-1)
for i in range(N-1):
    dp[i+K]=np.min(dp[i:i+K]+np.abs(H[i:i+K]-H[i+K]))
print(int(dp[-1]))

Measured memory_bytes: 23048
#include <bits/stdc++.h>
using namespace std;
int INF = 2000000000;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  int m = 0;
  for (int i = 0; i < n; i++){
    if (a[i] > m){
      m = a[i];
    }
  }
  int d = INF;
  int ans = -1;
  for (int i = 0; i < n; i++){
    if (abs(a[i] * 2 - m) < d && a[i] != m){
      d = abs(a[i] * 2 - m);
      ans = a[i];
    }
  }
  cout << m << ' ' << ans << endl;
}

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

int main() {
	
	int i, j, n, u, k, v, maxu, a[102][102] = {};
	
	cin >> n;
	maxu = 0;
	for (i = 0; i < n; i++) {
		cin >> u >> k;
		for (j = 0; j < k; j++) {
			cin >> v;
			a[u][v] = 1;
			maxu = max(maxu, u);
		}
	}

	for (i = 1; i <= maxu; i++) {
		for (j = 1; j <= maxu; j++) {
			if (j != 1)cout << " ";
			cout << a[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 3128
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H,A;
    cin >> H >> A;
    print((H+A-1) / A);
    

}

Measured memory_bytes: 256
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))

c = [[0] * w for _ in range(h)]
ai = 0

for i in range(h):
    f, e, s = 0, w, 1
    if i % 2: f, e, s = w-1, -1, -1 
    for j in range(f, e, s):
        ai += a[ai] <= 0
        a[ai] -= 1
        c[i][j] = ai+1

for l in c: print(*l)


Measured memory_bytes: 3920
#include<bits/stdc++.h>
using namespace std;
#define MN 100000
char s[MN+5];
int p[MN+5],pn;
int main()
{
	int n,i,j;
	scanf("%s",s+1);n=strlen(s+1);
	if(s[n]=='1'||s[1]=='0')return 0*puts("-1");
	for(i=1;i<n;++i)if(s[i]!=s[n-i])return 0*puts("-1");
	for(i=1;i<n;++i)if(s[i]=='1')p[++pn]=i;p[++pn]=n;
	for(i=1;i<pn;++i)for(j=p[i];j<p[i+1];++j)printf("%d %d\n",j,p[i+1]); 
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
map<int,int> mp;
int n;
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		int x;
		scanf("%d",&x);
		mp[x]++;
	}
	long long ans=0;
	for(auto x:mp) {
		if (x.second>=x.first) {
			ans+=x.second-x.first;
		} else {
			ans+=x.second;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4736
#include <iostream>
using namespace std;
int main(){
  int n;
  double sum=0;
  cin >> n;
  for (int i=0;i < n;i++){
    string s;
    double a;
    cin >> a >> s;
    if (s=="JPY") sum+=a;
    if (s=="BTC") sum+=(a*380000);
  }
  cout << sum << endl;
  return 0;
}
    

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

using namespace std;

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

const double pi = 3.14159265358979323846;

// #define fio() cin.tie(0); ios::sync_with_stdio(false);
// template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
// template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos

// 1e18

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

  ll H, W;
  cin >> H >> W;

  ll m = H * W;

  ll mod = 0;
  if (1 == H || 1 == W) {
    cout << 1 << endl;
  } else {
    cout << m / 2 + m % 2 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
using namespace std;
using ll =long long;
const int MOD = 1000000007;

int main() {
	ll K, N;
	ll c;
	
	cin >> N >> K;
	vector<ll>H;
	for (ll i = 0; i < N; i++) {	
		cin >> c;
		H.push_back(c);
	}
	sort(H.begin(), H.end());
	reverse(H.begin(), H.end());
	ll sum=0;
	if (K >= N) {


		cout << 0;
		return 0;
	}
	for (ll i = K; i < N;i++) {
	
		sum += H[i];
	
	}
	cout << sum;

}

Measured memory_bytes: 2420
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String c = saori.nextHayami();
		if(c.equals("a")){
			System.out.println("vowel");
		} else if(c.equals("i")){
			System.out.println("vowel");
		} else if(c.equals("u")){
			System.out.println("vowel");
		} else if(c.equals("e")){
			System.out.println("vowel");
		} else if(c.equals("o")){
			System.out.println("vowel");
		} else {
			System.out.println("consonant");
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21204
a,b,m=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

ma=int(1000000)
mb=int(1000000)
for i in range(a):
    if A[i]<ma:
        ma=A[i]
for i in range(b):
    if B[i]<mb:
        mb=B[i]

ans=ma+mb

for i in range(m):
    x,y,c=map(int,input().split())
    if A[x-1]+B[y-1]-c<ans:
        ans=A[x-1]+B[y-1]-c
print(ans)

Measured memory_bytes: 18684
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.List (unfoldr)
import Control.Monad (forM_)
import qualified Data.ByteString.Char8 as BS

main = do
  [n,k] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let m = (n - 1) * (n - 2) `quot` 2
  if k > m
    then putStrLn "-1"
    else do let l = m - k
            print $ n - 1 + l
            forM_ [2..n] $ \i -> do
              putStrLn $ unwords ["1", show i]
            let loop 0 !i !j = return ()
                loop l !i !j | j > n = loop l (i+1) (i+2)
                           | otherwise = do putStrLn $ unwords [show i, show j]
                                            loop (l - 1) i (j + 1)
            loop l 2 3


Measured memory_bytes: 1020
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<string, string> sP;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int px[6] = { 0,1,-1,1,0,1 }, py[6] = { -1,-1,0,0,1,1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

bool bpr[300100];

void sieve(int n) {
	for (int i = 0;i <= n;i++)bpr[i] = true;
	bpr[0] = bpr[1] = false;
	for (int i = 2;i <= n;i++) {
		if (bpr[i]) for (int j = i * 2;j <= n;j += i)bpr[j] = false;
	}
}

int main() {
	int q, l, r,rui[100010] = { 0 };
	sieve(100010);
	cin >> q;
	for (int i = 2;i <= 100000;i++) {
		if (bpr[i] && bpr[(i + 1) / 2])rui[i] = rui[i - 1] + 1;
		else rui[i] = rui[i - 1];
	}
	for (int i = 0;i < q;i++) {
		cin >> l >> r;
		cout << rui[r] - rui[l-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read() {
	int x=0;
	char ch=' ';
	bool flag=false;
	while(ch<'0' || ch>'9') {
		if(ch=='-')flag=true;
		ch=getchar();
	}
	while(ch>='0' && ch<='9') {
		x=(x<<3)+(x<<1)+ch-'0';
		ch=getchar();
	}
	return flag?-x:x;
}
const int MAX_N=100005;
int N,x[MAX_N];
int L,Q;
int F[MAX_N][35];
int main() {
	cin>>N;
	For(i,1,N)cin>>x[i];
	cin>>L>>Q;
	For(i,1,N) {
		F[i][0]=upper_bound(x+1,x+N+1,x[i]+L)-x-1;
	}
	For(j,1,30) {
		For(i,1,N) {
			F[i][j]=F[F[i][j-1]][j-1];
		}
	}
	while(Q--) {
		int a,b;
		cin>>a>>b;
		if(a>b)swap(a,b);
		int ans=0,v=a;
		per(i,30,0) {
			if(F[v][i]<b) {
				ans+=1<<i;
				v=F[v][i];
			}
		}
		cout<<ans+1<<endl;
	}
	return 0;
}



Measured memory_bytes: 14848
a,b,c = gets.split(" ").map(&:to_i)
k = gets.to_i

k.times do 
    if a >= b then
        b = b * 2
    elsif b >= c then
        c = c * 2
    end
    if a < b && b < c then
        break
    end
end

puts (a < b && b < c) ? "Yes" : "No"


Measured memory_bytes: 14340
#include<stdio.h>
int pop(void);
void push(int);
void enqueue(int,int);
int dequeue(int);
void assigncolor(void);
void DFS(int,int);

int n;
int head[100000],tail[100000];
int Q[100000][100];
int C[100000];
int size=0,S[100000];

int main(){
  int i;
  int m,s,t,q;
  scanf("%d%d",&n,&m);
  for(i=0;i<m;i++){
    scanf("%d%d",&s,&t);
    enqueue(s,t);
    enqueue(t,s);
  }
  assigncolor();
  scanf("%d",&q);
  int qs[q],qt[q];
  for(i=0;i<q;i++){
    scanf("%d%d",&qs[i],&qt[i]);
  }
  for(i=0;i<q;i++){
    if(C[qs[i]]==C[qt[i]]){
      printf("yes\n");
    }
    else{
      printf("no\n");
    }
  }
  return 0;
}
int pop(void){
  size--;
  return S[size];
}
void push(int n){
  S[size]=n;
  size++;
}
void enqueue(int s,int t){
  
  Q[s][tail[s]]=t;
  if(tail[s]+1==100){
    tail[s]=0;
  }
  else{
    tail[s]++;
  }
}

int dequeue(int s){

  int n;

  n=Q[s][head[s]];
  if(head[s]+1==100){
    head[s]=0;
  }
  else{
    head[s]++;
  }
  return n;
}

void assigncolor(void){
  int i;
  int id=1;
  for(i=0;i<n;i++){
    C[i]=-1;
  }
  for(i=0;i<n;i++){
    if(C[i]==-1){
      DFS(i,id++);
    }
  }
}

void DFS(int r,int c){
  int i;
  int u,v;
  push(r);
  C[r]=c;
  while(size!=0){
    u=pop();
    for(i=0;i<tail[u]-head[u];i++){ 
      v=Q[u][i];
      if(C[v]==-1){
	C[v]=c;
	push(v);
      }
    }
  }
}



Measured memory_bytes: 41712
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
 
ll MOD = 1000000007;
ll INF =1<<29;
ll dp[100100];
 
int main() {
     int a,b,c;
     cin >> a>>b>>c;
     cout << max(0,c-(a-b)) <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int colorflag[5][6];

void selectcolor(int panel[8][8],int flag[8][8],int h,int w,int count){
	int i, j;
	for(i = 0;i < 6;i++)
		colorflag[count][i] = 0;
	for(i = 0;i < h;i++){
		for(j = 0;j < w;j++){
			if(flag[i][j] == 1){
				if(i - 1 >= 0 && flag[i - 1][j] != 1) // 上
					colorflag[count][panel[i - 1][j] - 1] = 1;

				if(i + 1 < h && flag[i + 1][j] != 1) // 下
					colorflag[count][panel[i + 1][j] - 1] = 1;

				if(j - 1 >= 0 && flag[i][j - 1] != 1) // 左
					colorflag[count][panel[i][j - 1] - 1] = 1;

				if(j + 1 < w && flag[i][j + 1] != 1) // 右
					colorflag[count][panel[i][j + 1] - 1] = 1;
			}
		}
	}
}
void combine(int panel[8][8],int flag[8][8],int h,int w,int n,int count){
	int i, j;
	for(i = 0;i < h;i++){
		for(j = 0;j < w;j++){
			if(flag[i][j] == 1)
				panel[i][j] = n;
		}
	}
	selectcolor(panel,flag,h,w,count);
	while(colorflag[count][n - 1] == 1){
		for(i = 0;i < h;i++){
			for(j = 0;j < w;j++){
				if(flag[i][j] == 1){
					if(i - 1 >= 0 && panel[i - 1][j] == n) //上
						flag[i - 1][j] = 1;

					if(i + 1 < h && panel[i + 1][j] == n) //下
						flag[i + 1][j] = 1;

					if(j - 1 >= 0 && panel[i][j - 1] == n) //左
						flag[i][j - 1] = 1;

					if(j + 1 < w && panel[i][j + 1] == n) //右
						flag[i][j + 1] = 1;
				}
			}
		}
		selectcolor(panel,flag,h,w,count);
	}
}

int tmppanel[5][8][8], tmpflag[5][8][8];
void sub(int panel[8][8],int flag[8][8],int h,int w,int c,int count,int *max){
	int i, j, k, fcount;
	if(count < 4){
		selectcolor(panel,flag,h,w,count);
		for(i = 0;i < 6 && !colorflag[count][i];i++);
		if(i == 6){//　もし同じ色に染まったら
			*max = h * w;
			return;
		}
		for(i = 0;i < 6;i++){
			if(colorflag[count][i] == 1){
				for(j = 0;j < h;j++){
					for(k = 0;k < w;k++){
						tmppanel[count][j][k] = panel[j][k];
						tmpflag[count][j][k] = flag[j][k];
					}
				}
				combine(tmppanel[count],tmpflag[count],h,w,i + 1,count);
				sub(tmppanel[count],tmpflag[count],h,w,c,count + 1,max);
			}
		}
	}
	else if(count == 4){
		for(i = 0;i < h;i++){
			for(j = 0;j < w;j++){
				tmppanel[count][i][j] = panel[i][j];
				tmpflag[count][i][j] = flag[i][j];
			}
		}
		combine(tmppanel[count],tmpflag[count],h,w,c,count); // 結合する
		sub(tmppanel[count],tmpflag[count],h,w,c,count + 1,max);
		
	}
	else{
		fcount = 0;
		for(i = 0;i < h;i++){
			for(j = 0;j < w;j++){
				if(flag[i][j] == 1)
					fcount++;
			}
		}
		if(*max < fcount)
			*max = fcount;
	}
}

int main(void){
	int h, w, c, i, j, max = 0x80000000;
	int panel[8][8], flag[8][8];
	scanf("%d%d%d",&h,&w,&c);
	while(h != 0 || w != 0 || c != 0){
		for(i = 0;i < h;i++){
			for(j = 0;j < w;j++){
				flag[i][j] = 0;
				scanf("%d",&panel[i][j]);
			}
		}
		flag[0][0] = 1;
		combine(panel,flag,h,w,panel[0][0],0);
		sub(panel,flag,h,w,c,0,&max);
		printf("%d\n",max);
		max = 0x80000000;
		scanf("%d%d%d",&h,&w,&c);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}
pii Dir [] = {
	{ 1,0 },{ 0,1 }
};
signed main() {
	int n;
	scnaf("%d", &n);
	ll ans = 0,bef = -1;

	REP(i,n){
		ll a;
		scanf("%lld", &a);
		if (bef == -1) {
			bef = a % 2;
			ans += a / 2;
			continue;
		}
		ll nn = min(bef, a);
		ans += nn;
		a -= min(bef, a);
		ans += a / 2;
		bef = a%2;
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
    int N, a[100];

    cin >> N;

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

    int alice=0, bob=0;

    for (int i = 0; i < N; i++){        //偶数手番　アリス　奇数手番　ボブ
        int max = a[0];
        int max_id = 0;
        for (int j = 1; j < N; j++){    //最大値を得る
            if (max < a[j]){
                max = a[j];
                max_id = j;
            }
        }
        a[max_id] -= max;

        if (i%2 == 0){
            alice += max;
        } else {
            bob += max;
        }
    }
    int ans = alice - bob;

    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    String[] C = new String[H];
    for (int i = 0; i < H; i++) {
      C[i] = sc.next();
    }
    for (int i = 0; i < H; i++) {
      System.out.println(C[i]);
      System.out.println(C[i]);
    }
  }
}

Measured memory_bytes: 22916
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
import decimal

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()
i = 1
ans = INF
while i * i <= N:
    if N % i == 0:
        ans = i + N / i - 2
    i += 1
print ans

Measured memory_bytes: 4268
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DDiceInLine solver = new DDiceInLine();
        solver.solve(1, in, out);
        out.close();
    }

    static class DDiceInLine {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int n = s.nextInt(), k = s.nextInt();
            double ans, cur = 0;
            int[] p = new int[n];
            for (int i = 0; i < n; i++) p[i] = s.nextInt();
            for (int i = 0; i < k; i++) cur += (p[i] + 1) / 2.0;
            ans = cur;
            for (int i = k; i < n; i++) {
                cur -= (p[i - k] + 1) / 2.0;
                cur += (p[i] + 1) / 2.0;
                ans = Math.max(ans, cur);
            }
            w.println(ans);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 23348
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<functional>
#include<iomanip>
#define LLI long long int

using namespace std;

int main(){
		double a=0;
	int N;cin>>N;
	for(int i=0;i<N;i++){
		double tmp;
		cin>>tmp;
		a+=1/tmp;
	}
	cout<<fixed<<setprecision(7)<<(1/a)<<endl;

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define ll long long

ll change753(ll p[],int l){
	int i;
	for(i=0;i<l;i++){
		if(p[i]==0) p[i]=3;
		if(p[i]==1) p[i]=5;
		if(p[i]==2) p[i]=7;
	}
}

int main(void)
{
	//変数の宣言
	ll n;
	ll num[15];
	ll nextlen;
	ll ruijou;
	ll count3,count5,count7;
	ll roop;
	
	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	long long int temp,temp1,temp2;
	int max,min;
	int len;
	//データの読み込み
	
	scanf("%lld",&n);
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	for(i=3;i<15;i++){
		count=0;
		len=i;
		roop=1;
		for(j=0;j<len;j++){
			roop=roop*3;
			num[j]=0;
		}
		
		j=0;
		while(j<roop){
			temp=j;
			k=0;
			while(temp!=0){
				num[k]=temp%3;
				temp=temp/3;
				k++;
			}
			
//			for(k=0;k<len;k++){
//				printf("num[%d]=%d\n",k,num[k]);
//			}
			
			change753(num,len);
			
//			for(k=0;k<len;k++){
//				printf("num[%d]=%d\n",k,num[k]);
//			}
			
			ruijou=1;
			temp2=0;
			count3=0;
			count5=0;
			count7=0;
			for(k=0;k<len;k++){
//				printf("k=%d,temp2=%d\n",k,temp2);
				temp2=temp2+num[k]*ruijou;
				ruijou=ruijou*10;
				if(num[k]==3)count3++;
				if(num[k]==5)count5++;
				if(num[k]==7)count7++;
			}
			
//			printf("j=%d, temp2=%lld\n",j,temp2);
			
			if(temp2>n){
				printf("%d",ans);
				return 0;
			}else{
				if(count3>0&&count5>0&&count7>0){
					ans++;
//					printf("これは753数です count3=%d,count5=%d,count7=%d ans=%d\n",count3,count5,count7,ans);
				}else{
//					printf("これは753数ではありません\n");
				}
			}
			
			j++;
		}
	}
	
	
	
//	printf("計算部分終了\n");
	//出力
	
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}



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

void main_()
{
    array<uint64_t, 100> ln = {2, 1};

    int N;
    cin >> N;

    transform(begin(ln), begin(ln) + N - 1,
              ln.begin() + 1,
              ln.begin() + 2,
              plus<uint64_t>());

    cout << ln[N] << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
def main():
    import sys
    
    a, b, c, k = tuple(map(int, sys.stdin.readline().split()))
    
    total = 0
    if(k>a):
        total += 1*a
        k -= a
        if(k>b):
            k -= b
            if(k>c):
                total += -1*c
            else:
                total += -1*k
    else:
        total = 1*k
    print(total)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 61972
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C;
    cin >> A >> B >> C;
    if (A == B) {
        cout << C << endl;
    } else if (A == C) {
        cout << B << endl;
    } else {
        cout << A << endl;
    }

    return 0;
}


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

const int B=999999937;
const int P=1000000007;

void gen_hash(const string &s,vector<long long> &hash){
	long long c=0;
	for(int i=0;i<s.size();i++){
		c=(c*B+s[i])%P;
		hash[i]=c;
	}
}
long long pow_binary_mod(long long x,long long y,long long mod){
	long long z=1;
	for(;y;y>>=1){
		if((y&1)!=0)z=z*x%mod;
		x=x*x%mod;
	}
	return z;
}

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

	string s;
	cin>>s;
	int ls=s.size();
	vector<long long> v(ls),hsh(10001);
	gen_hash(s,v);

	//int T;
	//for(cin>>T;T--;){
		string q;
		cin>>q;
		int lq=q.size();
		gen_hash(q,hsh);
		long long hash=hsh[lq-1];
		long long Brev=pow_binary_mod(B,lq,P);
		vector<int> r;
		int i=lq-1;
		for(;i<ls;i++){
			if(v[i]==((i>=lq?v[i-lq]:0)*Brev+hash)%P){
				r.push_back(i-lq+1);
				//break;
			}
		}
		if(!r.empty()){
			for(int i=0;i<r.size();i++)printf("%d\n",r[i]);
			//puts("1");
		}else{
			//puts("0");
		}
	//}
}

Measured memory_bytes: 16540
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
#define fir first
#define sec second
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, s, k, ans, sum, last,a[200001];
struct Edge { LL to, cost; }; 
string str,ss;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n;
	rep(i,n) {
		cin >> a[i];
		if(i)
			if (a[i - 1] > 0&&a[i]>0) {
				a[i] -= 1;
				ans += 1;
			}
		ans += a[i] / 2;
		a[i] %= 2;
	}
	cout << ans << endl;
	return 0;
}


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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define fork(i,n) for(ll i=0; i<(n); i++)
#define forn for(ll i=0; i<(n); i++)
#define fori(i,k,n) for(ll i=k; i<(n); i++) 
#define all(x) (x).begin(),(x).end()
#define en '\n'
#define FILL(x,v) memset(x,v,sizeof(x))
#define pb push_back
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}
template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

void solve(){
	int n, k, c;
	cin >> n >> k >> c;
	string s; cin >> s;
	//O(2*N) // O(N)
	vi a(k), b(k);
	for(int i=0,j=0; i<n&&j<k; i++){
		if(s[i]=='o'){
			a[j++]=i;
			i+=c;//cooldown
		}
	}
	for(int i=n-1, j=k-1; ~i&&j>=0; --i){
		if(s[i]=='o'){
			b[j--]=i;
			i-=c;
		}
	}
	fork(i,k){
		if(a[i]==b[i])
			cout << a[i]+1 << en;
	}
}

int main(){
	fast;
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
		solve();
    return 0;
}

Measured memory_bytes: 3348
N, Q=map(int, input().split())
S=list(input())
L=[0]*(N)
s=[0]*(N+1)
for i in range(1,N):
  if S[i-1]=="A" and S[i]=="C":
    L[i]=1
    
for i in range(N):
  s[i+1]=s[i]+L[i]
for i in range(Q):
  l,r=map(int, input().split())
  print(s[r]-s[l])
  


Measured memory_bytes: 9204
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector<int> A(N), B(N);
	cat sum_in = 0, sum_out = 0;
	vector< pair<int, int> > val(2*N);
	for(int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
		sum_in += A[i];
		sum_out += B[i];
		val[2*i].ff = A[i];
		val[2*i+1].ff = B[i];
		val[2*i].ss = 2*i;
		val[2*i+1].ss = 2*i+1;
	}
	cat ans = min(sum_in, sum_out);
	sort(begin(val), end(val));
	cat sum = 0;
	for(int i = 0; i < N; i++) sum += val[i].ff;
	vector<int> posA(N), posB(N);
	for(int i = 0; i < 2*N; i++) {
		if(val[i].ss%2 == 0) posA[val[i].ss/2] = i;
		else posB[val[i].ss/2] = i;
	}
	for(int i = 0; i < N; i++) {
		int n = N;
		cat sum_cur = sum;
		if(posA[i] < n) {
			sum_cur -= val[posA[i]].ff;
			sum_cur += val[n].ff;
			n++;
		}
		if(posB[i] < n) {
			sum_cur -= val[posB[i]].ff;
			sum_cur += val[n].ff;
			n++;
		}
		if(posA[i] == n-1) {
			sum_cur -= val[posA[i]].ff;
			sum_cur += val[n].ff;
			n++;
		}
		ans = min(ans, sum_cur);
	}
	cout << ans << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 3456
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define tin cin>>t;while(t--)
#define pii pair<int,int>
#define endl '\n'
#define MIN -1000000000
#define flash ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

using namespace std;

ll int dp[100][100001]={-1};
ll int func(int n,int wt[],int v[],int w)
{
	//cout<<n<<" "<<dp[n]<<endl;
	
	if(w<0)
		return MIN;
  if(n<0||w==0)
		return 0;
	if(dp[n][w]==-1)
	{
		dp[n][w]=max(v[n]+func(n-1,wt,v,w-wt[n]),func(n-1,wt,v,w));
      
      //cout<<n<<" "<<w<<" "<<dp[n][w]<<endl;
	}
	return dp[n][w];

}


int main()
{
	int n,w;
	cin>>n>>w;
	int wt[n],v[n];
	for(int i=0;i<n;i++)
	{
		cin>>wt[i]>>v[i];
	}
	memset(dp,-1,sizeof(dp));
	cout<<func(n-1,wt,v,w)<<endl;
  
  
}

Measured memory_bytes: 78336
/**
     **author : _KMS_
     **created : 07-03-2020
**/
#include<bits/stdc++.h>
using namespace std;
const long long M =1e6,MOD=2e9;
typedef long long ll;
char ch[100][100],ch2[100][100];
int main() {
      
   ios::sync_with_stdio(false);
   cin.tie(0);
  int m,n;
  cin>>n>>m;
  for(int i=0;i<n;i++)
  for(int j=0;j<n;j++)cin>>ch[i][j];
  for(int i=0;i<m;i++)
  for(int j=0;j<m;j++)cin>>ch2[i][j];
  for(int i=0;i<=n-m;i++)
  {
        for(int j=0;j<=n-m;j++)
        {
              int c=0;
              bool f=1;
             for(int k=i;k<i+m;k++)
             {
                   int b=0;
                   for(int t=j;t<j+m;t++)
                   {
                         if(ch[k][t]!=ch2[c][b])
                         {
                               f=0;
                               break;
                         }
                         b++;
                   }
                   if(!f)break;
                   c++;
             }
             if(f)
             {
                   cout<<"Yes\n";
                   return 0;
             }
        }
  }
  cout<<"No\n";
   return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int ans = 0;
		String s = sc.next();
		for(int i = 0 ; i < s.length() - 1 ; i++) {
			if(s.charAt(i) != s.charAt(i + 1)) ans++;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 25280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

class Main {
	
	final static String SUNNY = "Sunny";
	final static String CLOUDY = "Cloudy";
	final static String RAINY = "Rainy";
	
    public static void main(String[] args) {
		OriginScanner os = new OriginScanner();
		PrintWriter pw = new PrintWriter(System.out);
		
		String weather = os.next();
		String next = null;
		
		switch (weather) {
			case SUNNY:
				next = CLOUDY;
				break;
			case CLOUDY:
				next = RAINY;
				break;
			case RAINY:
				next = SUNNY;
				break;
		}
		pw.println(next);
		pw.close();
	}
    
	static class OriginScanner {
		StringTokenizer token;
		BufferedReader br;
		
		public OriginScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		String nextLine() {
			String str = null;
			try {
				str = br.readLine();
			}
			catch (IOException e) {
				System.out.println(e);
			}
			return str;
		}
		
		String next() {
			while (token == null || !token.hasMoreElements()) { 
				token = new StringTokenizer(nextLine());
			}
			return token.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}

Measured memory_bytes: 19024
def combination(n, r):
    res = 1
    t = r - 1
    while t >= 0:
        res = res * (n - t) // (r - t)
        t -= 1
    return res

n,a,b = map(int, input().split())
v = list(map(int, input().split()))

v.sort()
v.reverse()

t = 0
for i in range(a):
    t += v[i]
t /= a
print(t)

cnt = 0
if v[0] == v[a-1]:
    candidate = 0
    cnt = 0
    for i in range(n):
        if v[i] == v[0]:
            candidate += 1
        else:
            break
    for i in range(a, min(b, candidate)+1):
        cnt += combination(candidate, i)
else:
    cnt = 0
    first = 50
    last = 0
    for i in range(n):
        if v[i] == v[a-1]:
            first = min(i, first)
            last = max(i, last)
    candidate = last - first + 1
    cnt += combination(candidate, a-first)
print(cnt)


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>

using ll = long long;
typedef unsigned long long ull;
typedef std::pair<int, int>p;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = false;
bool f = false;
bool used[210];
bool graph[100][100];
bool visited[8];
int abc[26] = { 0 };

int main() {
	int h, w;
	char c[10][10];
	bool b[10][10];
	std::cin >> h >> w;
	for (int i = 0;i < h;i++) {
		for (int j = 0;j < w;j++) {
			std::cin >> c[i][j];
			b[i][j] = false;
		}
	}
	int i = 0, j = 0;
	b[0][0] = true;
	while (i < h && j < w) {
		if (i + 1 < h&&c[i + 1][j] == '#') {
			b[i+1][j] = true;
			i++;
		}
		else if (j + 1 < w&&c[i][j + 1] == '#') {
			b[i][j + 1] = true;
			j++;
		}
		else break;
	}
	b[i][j] = true;
	for (int i = 0;i < h;i++) {
		for (int j = 0;j < w;j++) {
			if (c[i][j] == '#'&&b[i][j] == false) {
				std::cout << "Impossible" << std::endl;
				flag = false;
				break;
			}
		}
		if (flag == false)break;
	}
	if (flag)std::cout << "Possible" << std::endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
//#define mod 1000000007
#define pb push_back
typedef long long ll;
typedef long double ld;
#define FOR(i,n) for(i=0;i<n;i++)
#define FORE(i,n) for(i=0;i<=n;i++)
 
 
ll gcd(ll a , ll b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
   
}
    
ll maxl(ll a,ll b){
    if(a>b)return a;
    return b;
}
 
ll minl(ll a,ll b){
    if(a>b)return b;
    return a;
}
 
ll mod = 998244353;
 
ll mulmod(ll a, ll b,ll c){ 
    ll res = 0; 
    a = a % c; 
    while (b > 0){ 
        if (b % 2 == 1){ 
            res = (res + a) % c;
        }
        a = (a * 2) % c; 
        b /= 2; 
    } 
    return res % c; 
}
 
int binarySearch(int arr[], int l, int r, int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
        if (arr[mid] == x) 
            return mid; 
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
        return binarySearch(arr, mid + 1, r, x); 
    } 
    return -1; 
} 

int a[100005];
int tree[200005];

void build(int st,int low,int high){
    if(low==high){
        tree[st] = a[high]%2;
        return;
    }
    int mid = low+(high-low)/2;
    build(2*st,low,mid);
    build(2*st+1,mid+1,high);
    tree[st] = tree[2*st]+tree[2*st+1];
}

void update(int st,int start,int end,int ind,int val){
    if(start==end){
        tree[st] = val%2;
        return;
    }
    int mid = start+(end-start)/2;
    if(ind<=mid){
        update(2*st,start,mid,ind,val);
    }
    else update(2*st+1,mid+1,end,ind,val);
    tree[st] = tree[2*st]+tree[2*st+1];
}

int query(int st,int start,int end,int low,int high){
    if(start>high || end<low)return 0;
    int mid = start + (end-start)/2;
    if(start==low && end==high){
        return tree[st];
    }
    if(low>mid)return query(2*st+1,mid+1,end,low,high);
    if(high<=mid)return query(2*st,start,mid,low,high);
    return query(2*st,start,mid,low,mid)+query(2*st+1,mid+1,end,mid+1,high);
}

int main(){
	ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    map<string,int> m;
    string s;
    for(int i=0;i<n;i++){
        cin >> s;
        sort(s.begin(),s.end());
        if(m.find(s)==m.end())m[s] = 1;
        else m[s]++;
    }
    ll ans  = 0;
    for(auto it=m.begin();it!=m.end();++it){
        ll temp = it->second;
        ans+= ((temp)*(temp-1))/2;
    }
    cout << ans << endl;
	return 0;
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,h,w,ret=0; cin>>n>>h>>w;
	for (int i=0; i<n; i++) {
		int a,b; cin>>a>>b;
		if(a>=h&&b>=w) ret++;
	}
	cout<<ret<<"\n";
	return 0;
}

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

int main(){
    int N; cin >> N;
    string S; cin >> S;
    /*vector<char>Alphabet={'A','B','C',
    'D','E','F','G','H','I','J','K','L','M',
    'N','O','P','Q','R','S','T','U','V','W',
    'X','Y','Z'};*/
    string Alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    vector<int>cnt(26);
    for(int i=1;i<26;i++){
        cnt.at(i)=cnt.at(i-1)+1;
    }
    for(int i=0;i<S.size();i++){
        for(int j=0;j<26;j++){
            if(S.at(i)==Alphabet.at(j)){
                int digit=(j+N)%26;
                S.at(i)=Alphabet.at(digit);
                cout << S.at(i);
                break;
            }
        }
    }
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    static HashMap<Integer,ArrayList<Integer>> to = new HashMap<Integer,ArrayList<Integer>>();
    static int[] ans;
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        ans = new int[n];
        boolean[] wasCreated = new boolean[n];
        for(int i = 0; i < n-1; i++){
            int a = sc.nextInt()-1;
            int b = sc.nextInt()-1;
            if(wasCreated[a]){
                to.get(a).add(b);
            }else{
                ArrayList<Integer> arr = new ArrayList<Integer>();
                arr.add(b);
                to.put(a,arr);
                wasCreated[a] = true;
            }
            if(wasCreated[b]){
                to.get(b).add(a);
            }else{
                ArrayList<Integer> arr = new ArrayList<Integer>();
                arr.add(a);
                to.put(b,arr);
                wasCreated[b] = true;
            }
        }
        for(int i = 0; i < q; i++){
            int p = sc.nextInt()-1;
            int x = sc.nextInt();
            ans[p] += x;
        }
        dfs(0,-1);
        for(int i = 0; i < n; i++){
            System.out.print(ans[i] + " ");
        }
    }
    
    public static void dfs(int v, int p){
        for(int u : to.get(v)){
            if(u == p) continue;
            ans[u] += ans[v];
            dfs(u,v);
        }
    }
    
    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
             return Double.parseDouble(next());
         }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        } 
    }
}


Measured memory_bytes: 163632
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const ll mod=1e9+7;
const ll inf = (ll)1e17;
const ld eps = 1e-12;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}




int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll a,b;
    cin>>a>>b;
    ll res=a*500;
    if(res>=b){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;

}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> x(N, 0);
  
  for (int i = 0; i < N; i++) {
    cin >> x.at(i);
  }
  
  int dis = 0;
  
  for (int i = 0; i < N; i++) {
    dis += min(2 * (x.at(i) - 0), 2 * (K - x.at(i)));
  }
  
  cout << dis << endl;
  
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

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

    ll K, T;
    cin >> K >> T;

    vector<ll> a(T);
    rep (i, T) {
        cin >> a[i];
    }

    sort(a.begin(), a.end());

    ll tmp = a[T-1];
    ll sum = 0;
    rep (i, T-1) {
        sum += a[i];
    }

    if (tmp - sum > 1) {
        cout << tmp-sum-1 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

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

int main(){
	int N,M;
	cin >> N >> M;
	vector<int> L(M);
	vector<int> R(M);
	for(int i=0;i<M;i++){
		cin >> L.at(i)>>R.at(i);
	}
	int Lmax=*max_element(L.begin(),L.end());
	int Rmin=*min_element(R.begin(),R.end());

	cout<<max(0,Rmin-Lmax+1)<<endl;
	
}



Measured memory_bytes: 1024